1.Ctrl+Shift+'/' 将Java代码以/**/形式注释
2.所谓的相对路径是以index.jsp为准的
3.几个处理乱码的写法:
response.setContentType("text/html;charSet=GBK");
response.setCharacterEncoding("GBK");
强转:
String s = new String(s.getBytes("iso-8859-1"),"GBK");
表单提交时乱码:post时:
request.setCharacterEncoding("GBK");
注意:在取第一个参数前设置,只能解决Post提交乱码问题
对于Get下的乱码,修改Tomcat下conf下的server.xml文件
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" useBodyEncodingForURI="true" URIEncoding="GBK"/>
4.IE中Internet选项将隐私级别提高,可以控制网站向本机中写入Cooke
5.加入用户禁止了Cooke的写入,可以通过URL访问页面
例如:将链接方式:
<a href="<%=request.getContextPath() %>/Login/Login.jsp">管理员登录</a>
改为:
<a href="<%=response.encodeURL(request.getContextPath()+"/Login/Login.jsp")%>">管理员登录</a>
通过response.encodeURL()内的地址来完成转向
6.在Tomcat的web.xml中找到配置
<session-config> <session-timeout>30</session-timeout> </session-config>
改配置指明session对象在多长时间内没有使用,则服务器端进行回收。