jsp中的include静态页面出现乱码问题
在当前应用系统的web.xml里加入jsp-config代码:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<jsp-config>
<jsp-property-group>
<description>
Special property group for JSP Configuration JSP example.
</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.jsp</url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>GB2312</page-encoding>
<scripting-invalid>false</scripting-invalid>
<include-prelude></include-prelude>
<include-coda></include-coda>
<description>
Special property group for JSP Configuration JSP example.
</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.html</url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>GB2312</page-encoding>
<scripting-invalid>false</scripting-invalid>
<include-prelude></include-prelude>
<include-coda></include-coda>
</jsp-property-group>
</jsp-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
... ...
</webapp>
说明:<jsp-config>里的定义,就是通知当前应用服务器,当前应用系统下,所有的 .jsp, .html 文件,若是没有定义contentType="text/html;charset=gb2312" 时,就会采用预设的 "GB2312" 字符集去处理,如此,就不须要在每个 include 的档案第一行加上 contentType="text/html;charset=gb2312" 了。
相关文档:
昨天在写东西的时候,数据库用的编码是UTF-8,页面也是UTF-8,然后存进数据库的时发现还是乱码。中文的时候,随后debug,查到Action里面得到的表单内容也是乱码,哈哈
问题找到了,原来是Form表单或者其他地方有问题
后来在web.xml中加上对Spring编码的控制语句,好了...呵呵
......
request, reponse, out, session, application, config, pagecontext, page, exception.
一.request对象:该对象封装了用户提交的信息,通过调用该对象相应的方法可以获取封装的信息,即使用该对象可以获取用户提交信息。
1.Request对象可以使用getParameter(string s)方法获取该表单通过text提交的信息。如:
Requ ......
JSP中的pageEncoding和 contentType属性
关于JSP页面中的pageEncoding和contentType两种属性的区别:
pageEncoding是jsp文件本身的编码 contentType的charset是指服务器发送给客户端时的内容编码 JSP要经过两次的“编码”,第一阶会用pageEncoding,第二阶段会用utf-8至utf-8,第三阶段就是由Tomcat出来的网页 ......
一.什么是cookies?
大家都知道,浏览器与WEB服务器之间是使用HTTP协议进行通信的,当某个用户发出页面请求时,WEB服务器只是简单的进行响应,然后就关闭与该用户的连接。因此当一个请求发送到WEB服务器时,无论其是否是第一次来访,服务器都会把它当作第一次来对待,这样的不好之处可想而知。为了弥补这个缺陷,Netsc ......
//下面,从请求中得到属性 为一个 类,,会判断是否为null,,如为null则实例化
// id 值 相当于 class 的 对象名
<jsp:useBean id="order" class="com.entity.Order" scope="request" />
<==>
<%
Order order=(Order)request.getAttribute("order");
if(order==null)
  ......