老师的代码错误
还有0人有此问题
发表在JavaWeb图书答疑 2018-11-09
是否精华
版块置顶:

根申号老师您好!我是按照您视频中的代码来写的,但是您视频中说错误不要紧,是编译器没反应过来。

视频中的代码如下:

用户名:<%=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

错误日志如下:

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");


分享到:
精彩评论 2
无语_mrkj
学分:3155 LV11
2018-11-15
沙发

您重新启动一下服务器再运行试试呢?如果不行,把您的代码贴上来我们看一下。

15979526419
学分:147 LV3
2018-11-15
板凳

无语_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.


首页上一页 1 下一页尾页 2 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照