前端——第六天
一.JSP:JSP全名为Java Server Pages,中文名叫java服务器页面,其根本是一个简化的Servlet设计
1.JAVA页面中可以写java代码,语法:<% java代码 %> , <%=定义的变量 %>
2.<%@ include file="top.jsp" %>静态导入一个jsp页面 会报错,需要删除一些东西 与 <jsp:include page="top.jsp"/> 动态导入
3.注释:<!-- --> 能在源代码中看见 <%-- --%> 不能在源代码中看见
4.解决中文乱码的几种方法:
1.request.setCharacterEncoding("UTF-8");
2.String newstr = new String(username.getBytes("ISO-8859-1"),"UTF-8"); 单个转换
3.在\tomcat\conf\server.xml中第67行<Connector>标签中添加属性useBodyEncodingForURL="true"
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" useBodyEncodingForURL="true"/>
5.JSP页面中的九个内置对象