也试了,产生错误信息
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 170 in the jsp file: /www/logo.jsp
Generated servlet error:
[javac] Compiling 1 source file
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:299: unclosed string literal
response.sendRedirect("error.jsp?msg=<%=URLEncoder.encode('?ㄥソ????ユ????!')
^
An error occurred at line: 173 in the jsp file: /www/logo.jsp
Generated servlet error:
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:300: ')' expected
out.write("\");\r\n\t }\r\n\t \r\n\t %>");
^
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:309: 'catch' without 'try'
} catch (Throwable t) {
^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:31: 'try' without 'catch' or 'finally'
try {
^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:319: '}' expected
^
5 errors
我是直接搬上去的.
----------------解决方案--------------------------------------------------------
response.sendRedirect("error.jsp?msg=<%=URLEncoder.encode('?ㄥソ????ユ????!')
你这个写的问题吧!
URLEncoder需要引入java.net.URLEncoder
----------------解决方案--------------------------------------------------------
问题还是没有解决!
----------------解决方案--------------------------------------------------------
这个问题我也遇到过!其实只要把你要传递的信息先放到一个String里,
String urlr = "您的输入有误";
<p align='center'><a href='text.jsp?msg="+urlr+"'>" + name + "</a></p>"
然后在传过去之后进行如下转换
String url = request.getParameter("msg");
String urle = new String(url.getBytes("ISO-8859-1"),"GBK");
----------------解决方案--------------------------------------------------------
一般都用GBK吧你怎么又用GBK又用GB2312啊
----------------解决方案--------------------------------------------------------
加个filtter试试!!
----------------解决方案--------------------------------------------------------
据说utf8就不会了
----------------解决方案--------------------------------------------------------
在代码中加入这句话response.setContentType("text/html;charset=UTF8");
然后找到 server.xml 中的
<Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" URIEncoding='UTF8' />
加入红色部分代码,这样应该就行了。
如果还不行就把上面的UTF8全部替换成GBK.
----------------解决方案--------------------------------------------------------
String msg=new String(request.getParameter("msg").getBytes("iso-8859-1"));
"iso-8859-1"
----------------解决方案--------------------------------------------------------
我不是这样传回中文,我是要从这里传回:response.sendRedirect("error.jsp?msg=您的输入有误!");
error.jsp页面中的接收语句为:String msg=new String(request.getParameter("msg").getBytes("ISO8859_1"),"GBK");
----------------解决方案--------------------------------------------------------