这个jsp页面写死在代码里的东西在项目运行时也是乱码,搞了好久都没搞定 还请大家帮忙指点谢谢 <?xml version="1.0" encoding="GBK" ?>
<%@page language="java" contentType="text/html; charset=GBK"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%
String name = (String) session.getAttribute("name");
String groupname = (String) session.getAttribute("groupname" );
String nickname = (String)session.getAttribute("nickname");
%>
<script type="text/javascript" src="SpryAssets/setday.js"></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title> 处理 </title>
</head>
<body onload="init()">
<table width="100%" border="0" cellpadding="0" cellspacing="0" background ="/common/image/top_bg.gif" >
<tr>
<td align="center"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="260" align="left" style="width:260px; height:43px;"><a href="/index/index.jsp"><img src="/common/image/logo.gif" width="260" height="43" border="0"/></a></td>
<td align="left" valign="bottom" style="background-image:url(/common/image/top_right.gif); background-position:right; background-repeat:no-repeat; height:43px;"><table width="80%" height="24" border="0" cellpadding="0" cellspacing="0" class="t_font" >
<tr>
<td width="41%" align="center" nowrap="nowrap" valign="bottom"><span style="color:#FFFFFF;"><b><%=name %>(<%=groupname%>) 昵称 <%=nickname %> 工号 <%=session.getAttribute("employeenum") %> </b></span></td>
<td width="23%" valign="bottom" nowrap="nowrap"><h1><span style=" font-weight:bold; color:#FFFFFF; font-size:12px;"> 上次登录时间 <%=session.getAttribute("lastlogintime") %> </span></h1></td>
<td width="20%" align="left" nowrap="nowrap" valign="bottom"></td>
<td width="16%" align="left" nowrap="nowrap" valign="bottom" ><table width="90%" height="20" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom" nowrap="nowrap"><a href="/login/logout.do?mode=logout"><font style="color:#FFFFFF; font-weight:bold">安全退出></a> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table><form id="form1" name="form1" method="post" action="/excel/excel.do?">
<table width="100%" height="427" border="0">
<tr>
<th height="90" align="center" valign="middle"><div Id="tim1" Style="position:absolute; width:10; height:10; top:100; left:30"
class="time"></div><div Id="tim2"
Style="position:absolute; filter:flipv() alpha(opacity=20); font-style:italic" class="time"><p> </p></div></th>
<th height="90" align="center" valign="middle"><p> 查询日期范围:从 <input type="text" name="btime" id="btim"e onFocus="setday(this)" readonly="readonly"/> 到 <input type="text" name="etime" id="etime" onFocus="setday(this)" readonly="readonly"/>
</p>
<p>
<input type="button" name="Conform" id="Conform" value="开始查询" onClick="Tijiao()"/>
</p></th>
</tr>
<tr>
<td width="16%" height="331" ><div id="spryradio1">
<table width="200">
<tr>
<td><label>
<input name="RadioGroup1" type="radio" id="RadioGroup1_0" value="D" onSelect="content(D)">
担保</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="J" id="RadioGroup1_1" onClick="content(J)">
寄售</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="Z" id="RadioGroup1_2" onClick="content(Z)">
账号</label></td>
</tr>
</table>
<span class="radioRequiredMsg">请进行选择</span></div>
<p> </p>
<p>请选择组别:<br><select multiple="multiple" id="list1" name="list1" size="8">
<option value="J1">寄售一组</option>
<option value="J2">寄售二组</option>
<option value="J3">寄售三组</option>
<option value="J4">寄售四组</option>
<option value="D1">担保一组</option>
<option value="D2">担保二组</option>
<option value="D3">担保三组</option>
<option value="D4">担保四组</option>
<option value="Z1">账号一组</option>
<option value="Z2">账号二组</option>
</select>
<br><br><br>
已选择的组别:
<br>
<select multiple="multiple" id="list2" name="list2" size="8">
</select>
</p>
<p>
<input type="button" name="GameAdd" id="GameAdd" value="加入组别" onClick="move(this.form.list1,this.form.list2)"/>
<input type="button" name="GameDelete" id="GameDelete" value="删除组别" onClick="move(this.form.list2,this.form.list1)"/>
</p></td>
<td width="84%" nowrap="nowrap"><input type="text" id="1" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="2" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="3" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="4" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="5" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="6" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="7" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="8" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="9" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="10" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="11" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="12" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="13" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="14" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="15" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="16" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="17" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="18" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="19" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="20" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="21" name="GID" value="" disabled style="display:none" readonly="readonly"/>
</td>
</tr>
</table>
</form>
<p> </p></body>
</html>
<%@page language="java" contentType="text/html; charset=GBK"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%
String name = (String) session.getAttribute("name");
String groupname = (String) session.getAttribute("groupname" );
String nickname = (String)session.getAttribute("nickname");
%>
<script type="text/javascript" src="SpryAssets/setday.js"></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title> 处理 </title>
</head>
<body onload="init()">
<table width="100%" border="0" cellpadding="0" cellspacing="0" background ="/common/image/top_bg.gif" >
<tr>
<td align="center"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="260" align="left" style="width:260px; height:43px;"><a href="/index/index.jsp"><img src="/common/image/logo.gif" width="260" height="43" border="0"/></a></td>
<td align="left" valign="bottom" style="background-image:url(/common/image/top_right.gif); background-position:right; background-repeat:no-repeat; height:43px;"><table width="80%" height="24" border="0" cellpadding="0" cellspacing="0" class="t_font" >
<tr>
<td width="41%" align="center" nowrap="nowrap" valign="bottom"><span style="color:#FFFFFF;"><b><%=name %>(<%=groupname%>) 昵称 <%=nickname %> 工号 <%=session.getAttribute("employeenum") %> </b></span></td>
<td width="23%" valign="bottom" nowrap="nowrap"><h1><span style=" font-weight:bold; color:#FFFFFF; font-size:12px;"> 上次登录时间 <%=session.getAttribute("lastlogintime") %> </span></h1></td>
<td width="20%" align="left" nowrap="nowrap" valign="bottom"></td>
<td width="16%" align="left" nowrap="nowrap" valign="bottom" ><table width="90%" height="20" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom" nowrap="nowrap"><a href="/login/logout.do?mode=logout"><font style="color:#FFFFFF; font-weight:bold">安全退出></a> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table><form id="form1" name="form1" method="post" action="/excel/excel.do?">
<table width="100%" height="427" border="0">
<tr>
<th height="90" align="center" valign="middle"><div Id="tim1" Style="position:absolute; width:10; height:10; top:100; left:30"
class="time"></div><div Id="tim2"
Style="position:absolute; filter:flipv() alpha(opacity=20); font-style:italic" class="time"><p> </p></div></th>
<th height="90" align="center" valign="middle"><p> 查询日期范围:从 <input type="text" name="btime" id="btim"e onFocus="setday(this)" readonly="readonly"/> 到 <input type="text" name="etime" id="etime" onFocus="setday(this)" readonly="readonly"/>
</p>
<p>
<input type="button" name="Conform" id="Conform" value="开始查询" onClick="Tijiao()"/>
</p></th>
</tr>
<tr>
<td width="16%" height="331" ><div id="spryradio1">
<table width="200">
<tr>
<td><label>
<input name="RadioGroup1" type="radio" id="RadioGroup1_0" value="D" onSelect="content(D)">
担保</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="J" id="RadioGroup1_1" onClick="content(J)">
寄售</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="Z" id="RadioGroup1_2" onClick="content(Z)">
账号</label></td>
</tr>
</table>
<span class="radioRequiredMsg">请进行选择</span></div>
<p> </p>
<p>请选择组别:<br><select multiple="multiple" id="list1" name="list1" size="8">
<option value="J1">寄售一组</option>
<option value="J2">寄售二组</option>
<option value="J3">寄售三组</option>
<option value="J4">寄售四组</option>
<option value="D1">担保一组</option>
<option value="D2">担保二组</option>
<option value="D3">担保三组</option>
<option value="D4">担保四组</option>
<option value="Z1">账号一组</option>
<option value="Z2">账号二组</option>
</select>
<br><br><br>
已选择的组别:
<br>
<select multiple="multiple" id="list2" name="list2" size="8">
</select>
</p>
<p>
<input type="button" name="GameAdd" id="GameAdd" value="加入组别" onClick="move(this.form.list1,this.form.list2)"/>
<input type="button" name="GameDelete" id="GameDelete" value="删除组别" onClick="move(this.form.list2,this.form.list1)"/>
</p></td>
<td width="84%" nowrap="nowrap"><input type="text" id="1" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="2" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="3" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="4" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="5" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="6" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="7" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="8" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="9" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="10" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="11" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="12" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="13" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="14" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="15" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="16" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="17" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="18" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="19" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="20" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="21" name="GID" value="" disabled style="display:none" readonly="readonly"/>
</td>
</tr>
</table>
</form>
<p> </p></body>
</html>
解决方案 »
- 获取网页正文的思路
- Struts + Hibernate 多上传图片问题!
- jsp如何把excel导入sql??高手请进..
- 急啊!!!!我的图片显示不了了
- 怎么统计在线人数?(比如论坛中)
- 使用java判断字符串是否日日期类型
- 怪怪的问题,java.util.ArrayList的get()方法没有定义??
- 怎么控制crystal reports的详细资料里面的显示,急
- 一个巨弱的问题: 关于在JSP中加一段跳出框架代码,因何实现不了?
- getParameter是不是将页面提交的数据保存到数据库的唯一方法?谢谢
- 关于c3p0的配置启动tomcat出现的异常...
- struts1与struts2中由Action到JSP页面的传值问题
你用的是GBK。
你换个试试
pageEncoding="UTF-8"试试看
看看那上面的貌似也有个编码设置的,你找找看
pageEncoding="UTF-8"
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>处理</title>
</head>都為utf-8
解决方法
1、加过滤器package filters;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.UnavailableException;
public class SetCharacterEncodingFilter implements Filter {
/**
* The default character encoding to set for requests that pass through
* this filter.
*/
protected String encoding = null;
/**
* The filter configuration object we are associated with. If this value
* is null, this filter instance is not currently configured.
*/
protected FilterConfig filterConfig = null;
/**
* Should a character encoding specified by the client be ignored?
*/
protected boolean ignore = true;
// --------------------------------------------------------- Public Methods
/**
* Take this filter out of service.
*/
public void destroy() { this.encoding = null;
this.filterConfig = null; }
/**
* Select and set (if specified) the character encoding to be used to
* interpret request parameters for this request.
*
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException { // Conditionally select and set the character encoding to be used
if (ignore || (request.getCharacterEncoding() == null)) {
String encoding = selectEncoding(request);
if (encoding != null)
request.setCharacterEncoding(encoding);
} // Pass control on to the next filter
chain.doFilter(request, response); }
/**
* Place this filter into service.
*
* @param filterConfig The filter configuration object
*/
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null)
this.ignore = true;
else if (value.equalsIgnoreCase("true"))
this.ignore = true;
else if (value.equalsIgnoreCase("yes"))
this.ignore = true;
else
this.ignore = false; }
// ------------------------------------------------------ Protected Methods
/**
* Select an appropriate character encoding to be used, based on the
* characteristics of the current request and/or filter initialization
* parameters. If no character encoding should be set, return
* <code>null</code>.
* <p>
* The default implementation unconditionally returns the value configured
* by the <strong>encoding</strong> initialization parameter for this
* filter.
*
* @param request The servlet request we are processing
*/
protected String selectEncoding(ServletRequest request) { return (this.encoding); }
}在项目的web.xml中加入过滤器的配置
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC_JP</param-value>
</init-param>
</filter> <filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2、页面编码的设置,通常要为UTF-8
3、URL传中文参数在tomcat/conf/server.xml中找到
<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />
加encoding="utf-8"这些基本就可以了,还不行,就查google吧,这个问题自己解决一下就感觉豁然开朗了,这是一个思考问题的过程。
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Filter1 implements javax.servlet.Filter { public void destroy() {
} public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest req=(HttpServletRequest)request;
HttpServletResponse res=(HttpServletResponse)response;
req.setCharacterEncoding("GBK");
res.setCharacterEncoding("GBK");
request.setCharacterEncoding("GBK");
response.setContentType("text/html;charset=GBK");
chain.doFilter(request, response); } public void init(FilterConfig arg0) throws ServletException {
System.out.println("开始过滤........"); }}然后在web.xml中配上<filter>
<filter-name>filter</filter-name>
<filter-class>cn.com.comm.Filter1</filter-class>
</filter>
<filter-mapping>
<filter-name>filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
这样就差不多问题全解决了 需要分分分
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 对不同的字符显示结果不同而导致的。解决办法:在JSP页面中指定编码方式(gb2312),即在页面的第一 行加上: <%@ page contentType="text/html; charset=gb2312"%> 就可以消除乱码了。完整页面如下:
二、表单提交中文时出现乱码
<%@ page contentType="text/html; charset=gb2312"%> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 如果提交英文字符能正确显示,如果提交中文时就会出现乱码。原因:浏览器默认使用UTF -8编码方式来发送请求,而UTF- 8和GB2312编码方式表示字符时不一样,这样就出现了不能识别字符。 解决办法:通过request.seCharacterEncoding ("gb2312")对请求进行统一编码,就实现了中文的正常 显示。
三、数据库连接出现乱码 只要涉及中文的地方全部是乱码,解决办法:在数据库的数据库URL中加上 useUnicode=true&characterEncoding=GBK 就OK了。 四、数据库的显示乱码 在mysql4.1.0中,varchar类型,text类型就会出现中文乱码,对于varchar类型把它设为binary属性就 可以解决中文问题,对于text类型就要用一个编码转换类来处理,实现如下:
把它编译成class,就可以调用Convert类的静态方法ISOtoGB()来转换编码。 总结: 1. 在jsp中 <%@ page contentType="text/html; charset=A" %>如果指定了,那么在改jsp中所有构造 的String(不是引用),如果沒有指定编码,那么这些String的编码是A的。 从request的得到的String如果沒有指定request的编码的话,他是iso-8859-1的 从别的地方得到的String是使用原來初始的编码的,比如从数据库得到String,如果数据库的编码 是B,那么该String的编码是B而不是A的,也不是系统默认的。 此时,如果要输出的String的编码不是A,那么,很可能显示乱码的,所以首先要将String正確转化 为编码A的String,然后输出。 2. 在jsp中 <%@ page contentType="text/html; charset=A" %> 沒有指定,那么相当于指定了 <%@ page contentType="text/html; charset=ISO-8859-1" %> 3. Servelte中如果执行了像 response.setContentType("text/html;charset=A");説明将response的 字符输出流编码设置为A,所有要输出的String的编码要转化为A的,否則会得到乱码的。 Servelet中从request得到的String的编码和jsp中一样的,但是在servlet java文件中构造的 String是使用的系统默认的编码的。在servelt中从外部得到的String 是使用原来的编码的,比如从编 码为B的数据库得到的数据是编码为B的,不是A,也不是系统默认的编码。 JSP中文乱码问题解决方法小结 在使用JSP的过程中,最使人头疼的一个问题就是中文乱码问题,以下是我在软件开发中遇到的乱 码问题以及解决方法。 1、JSP页面乱码 这种乱码的原因是应为没有在页面里指定使用的字符集编码,解决方法:只要在页面开始地方用下 面代码指定字符集编码即可, 2、数据库乱码 这种乱码会使你插入数据库的中文变成乱码,或者读出显示时也是乱码,解决方法如下: 在数据库连接字符串中加入编码字符集
String Url="jdbc:mysql://localhost/digitgulf? user=root&password=root&useUnicode=true&characterEncoding=GB2312"; 并在页面中使用如下代码: response.setContentType("text/html;charset=gb2312"); request.setCharacterEncoding("gb2312"); 3、中文作为参数传递乱码 当我们把一段中文字符作为参数传递个另一页面时,也会出现乱码情况,解决方法如下: 在参数传递时对参数编码,比如
RearshRes.jsp?keywords=" + java.net.URLEncoder.encode(keywords)
然后在接收参数页面使用如下语句接收
keywords=new String(request.getParameter("keywords").getBytes("8859_1"));
4、JSP页面乱码加这句
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="err.jsp" %> JSP的request 默认为ISO8859_1,所以在处理中文的时候, 要显示中文的话,必须转成GBK的,如下 String str=new String(request.getParameter("name").getBytes("ISO8859-1"),"GBK"); out.println(str); 这样就可以显示中文了 1.插入中文: String sql2="INSERT INTO test (name) VALUES('"+request.getParameter("name")+"')"; stmt.executeUpdate(sql2); 不用编码就可以插入了 2.显示插入的中文: 因为存入的是latin,所以显示的时候就要GBK一下 String x=new String((rs.getString("title")).getBytes("ISO8859_1"),"GBK"); out.println(x); 3.设定存储编码: 当然在MySQL为latin1编码时,也可以存的时候用GBK了 Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp? useUnicode=true&characterEncoding=GBK","root",""); str1="中文"; String sql2="INSERT INTO test (name) VALUES('"+str1+"')"; 这样也可以很成功的插入了,呵呵
<%@page language="java" contentType="text/html; charset=utf-8" enconding="utf-8"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%
String name = (String) session.getAttribute("name");
String groupname = (String) session.getAttribute("groupname" );
String nickname = (String)session.getAttribute("nickname");
%>
<script type="text/javascript" src="SpryAssets/setday.js"></script>
<head>
<title> 处理 </title>
</head>
<body onload="init()">
<table width="100%" border="0" cellpadding="0" cellspacing="0" background ="/common/image/top_bg.gif" >
<tr>
<td align="center"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="260" align="left" style="width:260px; height:43px;"><a href="/index/index.jsp"><img src="/common/image/logo.gif" width="260" height="43" border="0"/></a></td>
<td align="left" valign="bottom" style="background-image:url(/common/image/top_right.gif); background-position:right; background-repeat:no-repeat; height:43px;"><table width="80%" height="24" border="0" cellpadding="0" cellspacing="0" class="t_font" >
<tr>
<td width="41%" align="center" nowrap="nowrap" valign="bottom"><span style="color:#FFFFFF;"><b><%=name %>(<%=groupname%>) 昵称 <%=nickname %> 工号 <%=session.getAttribute("employeenum") %> </b></span></td>
<td width="23%" valign="bottom" nowrap="nowrap"><h1><span style=" font-weight:bold; color:#FFFFFF; font-size:12px;"> 上次登录时间 <%=session.getAttribute("lastlogintime") %> </span></h1></td>
<td width="20%" align="left" nowrap="nowrap" valign="bottom"></td>
<td width="16%" align="left" nowrap="nowrap" valign="bottom" ><table width="90%" height="20" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom" nowrap="nowrap"><a href="/login/logout.do?mode=logout"><font style="color:#FFFFFF; font-weight:bold">安全退出></a> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table><form id="form1" name="form1" method="post" action="/excel/excel.do?">
<table width="100%" height="427" border="0">
<tr>
<th height="90" align="center" valign="middle"><div Id="tim1" Style="position:absolute; width:10; height:10; top:100; left:30"
class="time"></div><div Id="tim2"
Style="position:absolute; filter:flipv() alpha(opacity=20); font-style:italic" class="time"><p> </p></div></th>
<th height="90" align="center" valign="middle"><p> 查询日期范围:从 <input type="text" name="btime" id="btim"e onFocus="setday(this)" readonly="readonly"/> 到 <input type="text" name="etime" id="etime" onFocus="setday(this)" readonly="readonly"/>
</p>
<p>
<input type="button" name="Conform" id="Conform" value="开始查询" onClick="Tijiao()"/>
</p></th>
</tr>
<tr>
<td width="16%" height="331" ><div id="spryradio1">
<table width="200">
<tr>
<td><label>
<input name="RadioGroup1" type="radio" id="RadioGroup1_0" value="D" onSelect="content(D)">
担保</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="J" id="RadioGroup1_1" onClick="content(J)">
寄售</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="Z" id="RadioGroup1_2" onClick="content(Z)">
账号</label></td>
</tr>
</table>
<span class="radioRequiredMsg">请进行选择</span></div>
<p> </p>
<p>请选择组别:<br><select multiple="multiple" id="list1" name="list1" size="8">
<option value="J1">寄售一组</option>
<option value="J2">寄售二组</option>
<option value="J3">寄售三组</option>
<option value="J4">寄售四组</option>
<option value="D1">担保一组</option>
<option value="D2">担保二组</option>
<option value="D3">担保三组</option>
<option value="D4">担保四组</option>
<option value="Z1">账号一组</option>
<option value="Z2">账号二组</option>
</select>
<br><br><br>
已选择的组别:
<br>
<select multiple="multiple" id="list2" name="list2" size="8">
</select>
</p>
<p>
<input type="button" name="GameAdd" id="GameAdd" value="加入组别" onClick="move(this.form.list1,this.form.list2)"/>
<input type="button" name="GameDelete" id="GameDelete" value="删除组别" onClick="move(this.form.list2,this.form.list1)"/>
</p></td>
<td width="84%" nowrap="nowrap"><input type="text" id="1" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="2" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="3" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="4" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="5" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="6" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="7" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="8" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="9" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="10" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="11" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="12" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="13" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="14" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="15" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="16" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="17" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="18" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="19" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="20" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="21" name="GID" value="" disabled style="display:none" readonly="readonly"/>
</td>
</tr>
</table>
</form>
<p> </p></body>
</html>
<%@page language="java" contentType="text/html; charset=utf-8" enconding="utf-8"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%
String name = (String) session.getAttribute("name");
String groupname = (String) session.getAttribute("groupname" );
String nickname = (String)session.getAttribute("nickname");
%>
<script type="text/javascript" src="SpryAssets/setday.js"></script>
<head>
<title> 处理 </title>
</head>
<body onload="init()">
<table width="100%" border="0" cellpadding="0" cellspacing="0" background ="/common/image/top_bg.gif" >
<tr>
<td align="center"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="260" align="left" style="width:260px; height:43px;"><a href="/index/index.jsp"><img src="/common/image/logo.gif" width="260" height="43" border="0"/></a></td>
<td align="left" valign="bottom" style="background-image:url(/common/image/top_right.gif); background-position:right; background-repeat:no-repeat; height:43px;"><table width="80%" height="24" border="0" cellpadding="0" cellspacing="0" class="t_font" >
<tr>
<td width="41%" align="center" nowrap="nowrap" valign="bottom"><span style="color:#FFFFFF;"><b><%=name %>(<%=groupname%>) 昵称 <%=nickname %> 工号 <%=session.getAttribute("employeenum") %> </b></span></td>
<td width="23%" valign="bottom" nowrap="nowrap"><h1><span style=" font-weight:bold; color:#FFFFFF; font-size:12px;"> 上次登录时间 <%=session.getAttribute("lastlogintime") %> </span></h1></td>
<td width="20%" align="left" nowrap="nowrap" valign="bottom"></td>
<td width="16%" align="left" nowrap="nowrap" valign="bottom" ><table width="90%" height="20" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom" nowrap="nowrap"><a href="/login/logout.do?mode=logout"><font style="color:#FFFFFF; font-weight:bold">安全退出></a> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table><form id="form1" name="form1" method="post" action="/excel/excel.do?">
<table width="100%" height="427" border="0">
<tr>
<th height="90" align="center" valign="middle"><div Id="tim1" Style="position:absolute; width:10; height:10; top:100; left:30"
class="time"></div><div Id="tim2"
Style="position:absolute; filter:flipv() alpha(opacity=20); font-style:italic" class="time"><p> </p></div></th>
<th height="90" align="center" valign="middle"><p> 查询日期范围:从 <input type="text" name="btime" id="btim"e onFocus="setday(this)" readonly="readonly"/> 到 <input type="text" name="etime" id="etime" onFocus="setday(this)" readonly="readonly"/>
</p>
<p>
<input type="button" name="Conform" id="Conform" value="开始查询" onClick="Tijiao()"/>
</p></th>
</tr>
<tr>
<td width="16%" height="331" ><div id="spryradio1">
<table width="200">
<tr>
<td><label>
<input name="RadioGroup1" type="radio" id="RadioGroup1_0" value="D" onSelect="content(D)">
担保</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="J" id="RadioGroup1_1" onClick="content(J)">
寄售</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="Z" id="RadioGroup1_2" onClick="content(Z)">
账号</label></td>
</tr>
</table>
<span class="radioRequiredMsg">请进行选择</span></div>
<p> </p>
<p>请选择组别:<br><select multiple="multiple" id="list1" name="list1" size="8">
<option value="J1">寄售一组</option>
<option value="J2">寄售二组</option>
<option value="J3">寄售三组</option>
<option value="J4">寄售四组</option>
<option value="D1">担保一组</option>
<option value="D2">担保二组</option>
<option value="D3">担保三组</option>
<option value="D4">担保四组</option>
<option value="Z1">账号一组</option>
<option value="Z2">账号二组</option>
</select>
<br><br><br>
已选择的组别:
<br>
<select multiple="multiple" id="list2" name="list2" size="8">
</select>
</p>
<p>
<input type="button" name="GameAdd" id="GameAdd" value="加入组别" onClick="move(this.form.list1,this.form.list2)"/>
<input type="button" name="GameDelete" id="GameDelete" value="删除组别" onClick="move(this.form.list2,this.form.list1)"/>
</p></td>
<td width="84%" nowrap="nowrap"><input type="text" id="1" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="2" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="3" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="4" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="5" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="6" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="7" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="8" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="9" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="10" name="GID" value="" disabled style="display:none" readonly="readonly"/><br>
<input type="text" id="11" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="12" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="13" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="14" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="15" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="16" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="17" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="18" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="19" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="20" name="GID" value="" disabled style="display:none" readonly="readonly"/>
<input type="text" id="21" name="GID" value="" disabled style="display:none" readonly="readonly"/>
</td>
</tr>
</table>
</form>
<p> </p></body>
</html>
<%@page language="java" contentType="text/html; charset=utf-8" enconding="utf-8"%>
2,编写字符编码过滤器。(该类可以直接拿过去用)
package com.mww.comm;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class checkEcodingFelter implements Filter { public void destroy() {
// TODO Auto-generated method stub } public void doFilter(ServletRequest servletrequest,
ServletResponse servletresponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletrequest;
HttpServletResponse response = (HttpServletResponse) servletresponse;
request.setCharacterEncoding("UTF-8");//设置请求编码为UTF-8
response.setCharacterEncoding("UTF-8");//设置响应编码为UTF-8
response.setContentType("text/html;charset=UTF-8");//页面编码为UTF-8
filterChain.doFilter(servletrequest, servletresponse);//放行 } public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub }}
然后在web.xml中配置该过滤器 配置如下:
<!-- 字符编码过滤 -->
<filter>
<filter-name>checkEcodingFelter</filter-name>
<filter-class>com.mww.comm.checkEcodingFelter</filter-class>
</filter>
<filter-mapping>
<filter-name>checkEcodingFelter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>3,在tomacat 中的conf文件夹中的server.xml 这个配置文件上加上如下代码,以后就不用改了,都用UTF-8编码的 配置:(在配置端口号的节点上加上:URIEncoding="UTF-8")详细如下:
<Connector port="9000" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"/>
如果你做到这几点字符编码问题应该就不会存在在了。
中的charset=GBK 改成 Charset=GBK 试试看
我试过有用的
感觉你安装MYECLIPSE的时候设置编码出错了吧???
如果用dw新建的页面,用eclipse打开可能会出现乱码问题。
跟IE有些不兼容
方法:16楼写的很清楚
下面java脚本里添加request.setCharacterEncoding("gbk");
上面的;号后没有空格吧?
而且用dw,它会以 utf-8的编码保存,用记事本一类的打开,另存为时选择 ansi编码试试看,以前我也出过类似的问题。