<%@ page language="java" contentType="text/html; charset=GBK"%>
<html>
<head>
<title></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
</head>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/theme/9/style.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/theme/neotech.net/webmail.css">
<body class="bodycolor" leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>
<br/>
<br/>
<p style="text-align: center;">搜索</p>
</body>
</html>运行后页面上显示的是两个 ??
无语了...
求解决办法...
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
1.一个页面的编码格式,
2.tomcat下server.xml文件中配置的URIencoding是否与页面编码格式一致
3.java文件的编码格式是否一致。
然后看你服务器的运行环境里面配置是不是一样的编码格式,配置路径是在server.xml文件里面加个参数就行了
<body>
request.setCharacterEncoding("GBK");
</body>
应该是这个是对的
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="GBK"/>
添加 过滤器
我的这样写的
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
如过是请在本页面加上这句话 response.setCharacterEncoding("gbk");
如果你是在所项目我也建议你用过滤器
web.xml配置文件写法如logiv给你回复的内容
2. 把正常页面的头信息拷过来试试。
3. 新建个jsp,重写代码。如果有一种能解决,在和原来的代码比较下,应该就能找到问题了
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />修改为
<Connector port="80" protocol="HTTP/1.1" useBodyEncodingForURI="true" URIEncoding="UTF-8"
connectionTimeout="20000"
redirectPort="8443" />