无语_mrkj 发表于2018-11-15 16:37
您重新启动一下服务器再运行试试呢?如果不行,把您的代码贴上来我们看一下。
老师您好,我这个web项目下有3个jsp文件 代码是和根申号老师视频课程里面一样的
client.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<ul>
<li>客户端使用协议:<%=request.getProtocol() %></li>
<li>客户端发送请求的方法:<%=request.getMethod() %></li>
<li>客户端的请求路径:<%=request.getContextPath() %>
<li>客户端的IP地址:<%=request.getRemoteAddr() %>
<li>客户端的主机名称:<%=request.getRemoteHost() %>
<li>客户端端口号:<%=request.getRemotePort() %>
<li>接受客户信息的页面:<%=request.getServletPath() %>
</ul>
</body>
</html>
show.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
用户名:<%=new String(request.getParameter("name").getBytes("ISO8859_1"),"UTF-8")%><br>
性别<%=new String(request.getParameter("sex").getBytes("ISO8859_1"),"UTF-8") %><br>
密码提示问题<%=new String(request.getParameter("question").getBytes("ISO8859_1"),"UTF-8") %><br>
问题答案<%=new String(request.getParameter("answer").getBytes("IOS8859_1"),"UTF-8") %><br>
个人爱好
<%
String[] like=request.getParameterValues("like");
for(int i=0;i<like.length;i++){%>
<%=new String (like[i].getBytes("ISO8859_1"),"UTF-8") %>
<%
}
%>
</body>
</html>
NewFile.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="show.jsp" method="post">
请输入用户姓名<input type="text" name="name"><br>
选择性别<input type="radio" name="sex" value="男" >男
<input type="radio" name="sex" value="女">女<br>
请选择密码提示问题
<select name="question">
<option value="母亲的生日" >母亲的生日</option>
<option value="父亲的名字">父亲的名字</option>
</select><br>
请输入密码答案
<input type="text" name="answer" ><br>
请选择个人爱好
<input type="checkbox" name="like" value="唱歌跳舞">唱歌跳舞
<input type="checkbox" name="like" value="户外登山">户外登山
<input type="checkbox" name="like" value="网上冲浪" >网上冲浪
<input type="submit" value="提交">
</form>
</body>
</html>
web.xml如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>MyWeb</display-name>
<welcome-file-list>
<welcome-file>NewFile.jsp</welcome-file>
</welcome-file-list>
</web-app>
点提交按钮就会出现如下错误
HTTP Status 500 – Internal Server Error
Type Exception Report
Message An exception occurred processing [/show.jsp] at line [13]
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
java.io.IOException: An exception occurred processing [/show.jsp] at line [13]
10: 鐢ㄦ埛鍚嶏細<%=new String(request.getParameter("name").getBytes("ISO8859_1"),"UTF-8")%><br>
11: 鎬у埆<%=new String(request.getParameter("sex").getBytes("ISO8859_1"),"UTF-8") %><br>
12: 瀵嗙爜鎻愮ず闂<%=new String(request.getParameter("question").getBytes("ISO8859_1"),"UTF-8") %><br>
13: 闂绛旀<%=new String(request.getParameter("answer").getBytes("IOS8859_1"),"UTF-8") %><br>
14: 涓汉鐖卞ソ
15: <%
16: String[] like=request.getParameterValues("like");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:486)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
java.io.UnsupportedEncodingException: IOS8859_1
java.lang.StringCoding.encode(Unknown Source)
java.lang.String.getBytes(Unknown Source)
org.apache.jsp.show_jsp._jspService(show_jsp.java:134)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:458)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Note The full stack trace of the root cause is available in the server logs.