register.jsp
年龄:<input type="text" name="uage1" /> <br />
show.jsp
int age1=Integer.parseInt(request.getParameter("uage1"));
老是null..........
HTTP状态 500 - 内部服务器错误
类型 异常报告
消息 在 [18] 行处理 [/showes.jsp] 时发生异常
描述 服务器遇到一个意外的情况,阻止它完成请求。
例外情况
org.apache.jasper.JasperException: 在 [18] 行处理 [/showes.jsp] 时发生异常
15: String pwd = request.getParameter("upwd");
16: String Surname = request.getParameter("uSurname");
17: String name = request.getParameter("uname");
18: int age1=Integer.parseInt(request.getParameter("uage1"));
19: String china = request.getParameter("uchina");
20: String phone = request.getParameter("uphone");
21: String[] hobbies = request.getParameterValues("uhobbies");
Bored to death
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<from action ="check.jsp" method = "post" >
用户名:<input type = "text" name = "uname"><br/>
用户密码:<input type = "password" name = "upwd"><br/>
<input type = "submit" value = "登陆"><br/>
</from>
</body>
</html>
《登录页面》
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String name = request.getParameter("uname");
String pwd = request.getParameter("upwd");
if(name.equals("zs") && pwd.equals("123")){
//页面跳转,重定向,数据丢失;
//response.sendRedirect("success.jsp");
//页面跳转,请求转发;地址栏不变
request.getRequestDispatcher("success.jsp").forward(request, response);
} else {
out.print("用户名或用户密码错误。。。");
}
%>
</body>
</html>
《检查页面》
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>登陆成功</h1>
<h2>欢迎您。。。</h2>
<%
String name = request.getParameter("uname");
out.print(name);
%>
</body>
</html>
《转至成功页面》
问题是根本跳不动检查页面,服务器也不报错。那后面的成功页面也就是无稽之谈了。。
把你提交数据的整个html和js贴上,只看到这一部分很难看出
request.getRequestDispatcher("success.jsp").forward(request, response);
你在这上面打印一下入参。看看有没有先,一步步分析。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action ="check.jsp" method = "post" >
用户名:<input type = "text" name = "uname"><br/>
用户密码:<input type = "password" name = "upwd"><br/>
<input type = "submit" value = "登陆"><br/>
</form>
</body>
</html>
<form></form>这写错了!!!!