以下是两个jsp页面:
test.jsp:<a herf="test.jsp?value=中文">测试</a>testValue.jsp:
<% request.getParameter("value");>请问如何设置两个页面的编码才能正确的显示所有的中文字体???
test.jsp:<a herf="test.jsp?value=中文">测试</a>testValue.jsp:
<% request.getParameter("value");>请问如何设置两个页面的编码才能正确的显示所有的中文字体???
解决方案 »
- struts2 批量提交问题
- 求助各位高手
- java.sql.SQLException: Io exception 的2个问题,50分/题
- UTF-8页面读数据库中UTF-8数据时 为什么是乱码?
- JdonFramework是什么东东?
- 在JBuilder9.0 怎样把tomcat4.1 升级到 tomcat 5.0 ,请各路大侠伸出援助之手
- 为何通过链接传过去的值只能正常显示数字,字母和中文都是乱码。
- 为什么不能更新呢
- 写了一个操作数据库的问题:用火狐可以添加成功,IE不成功,不知道怎么回事?
- JBuilder7开发JSP
- 页面的加了这个上传的enctype="multipart/form-data,怎么取字段的数组值,不能request.getParameterValues(""),急!!!
- 如何将有表格、图片内容的word文档添加到数据库中!
只不过在取参数的时候使用
String str = new String(request.getParameter("value"),"ISO-8859-1");
就是在request.getParameter之前进行中文字符的转化,要在哪个界面显示就在哪个界面加入String str = new String(request.getParameter("value"),"ISO-8859-1")进行字符串转换。
我就不明白为什么我们中文就得转呢,郁闷!!!!
我尝试用String(request.getParameter("value").getBytes(),"ISO-8859-1"),可是没有用.有其他正确的方法吗?
request.setCharacterEncoding("gb2312");
或者用过滤器也行
我的服务器是tomcat
<%request.setCharacterEncoding("gb2312");%>
我使用的是tomcat,是不是要设置一下?
test.jsp:
<a herf="test.jsp?value=中文">测试</a>应该是这样的吧:<a herf="testValue.jsp?value=中文">测试</a> 在前面加上两行:
<%@page contentType="text/html;charset=gb2312"%>(页面显示的字符编码是gb2312)
<%request.setCharacterEncoding("gb2312");%>(用户请求中包含的参数字符编码是gb2312)与汤母猫无关
java.net.URLDecode.decode(获得的值);
<head>
<%@ page
language="java"
contentType="text/html; charset=GBK"
pageEncoding="GBK"
%>
...
</head>
<body>
<a href="testValue.jsp?value=中文">测试</a>
</body>
testValue.jsp:
<head>
<%@ page
language="java"
contentType="text/html; charset=GBK"
pageEncoding="GBK"
%>
...
</head>
<body>
<%=new String(request.getParameter("value").getBytes("ISO8859_1"))%>
</body>
加在前面