Tomcat 自定义错误页

conf/server.xml 中的 Host标签添加

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<Host name="localhost"  appBase="webapps"
      unpackWARs="true" autoDeploy="true">
  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
         prefix="localhost_access_log" suffix=".txt"
         pattern="%h %l %u %t &quot;%r&quot; %s %b" />

    // 这是新加的
    <Valve className="org.apache.catalina.valves.ErrorReportValve"
              errorCode.400="webapps/ROOT/error.jsp"
              errorCode.0="webapps/ROOT/error.jsp"
              showReport="false"
              showServerInfo="false" />
    // 这是新加的
</Host>

上面的 error.jsp 放在 webapps/ROOT/

在 Js 中统一设置请求参数的另一种方法

  • 重写方法XMLHttpRequest.prototype.send
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11

XMLHttpRequest.prototype._send = XMLHttpRequest.prototype.send
XMLHttpRequest.prototype.send = function (params) {
	var attached_params = mdcUtil.MDC_DEVICE_ID + "=" + mdcUtil.getMdcDeviceId();
	if (params) {
		params += "&" + attached_params;
	} else {
		params = attached_params;
	}
	return this._send(params)
}

Java 出现内存分配失败

问题

If you see that the storm process is getting crashed even though you have enough memory (swap/free) available then you should also check the “/proc/sys/vm/overcommit_memory

  • This switch knows 3 different settings:

=> 0: The Linux kernel is free to over commit memory(this is the default), a heuristic algorithm is applied to figure out if enough memory is available.