您的位置:首页 > 产品设计 > UI/UE

The server encountered an internal error () that prevented it from fulfilling this request.

2014-10-05 23:56 776 查看
错误提示:

The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
com.pb.web.action.LoginAction.login(LoginAction.java:18)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)

解释:在if(user.getUserName().equals("aptech")&&user.getPassword().equals("ok")){
System.out.println("到这里了2");
return "success";
}else{
return "input";
}
中(user.getUserName().equals("aptech")&&user.getPassword().equals("ok")这句有问题,当换用ture时,程序可以往下走。根据提示,是不能正常初始化,我这里用的是

属性的方式传递参数。

解决办法:经仔细检查,发现在form表单中有错误。因为我采用的是JavaBean的方式传送数据,所以标签input中的name="userName"应该写成name="user.userName"。

此外,在显示页面中,属性页必须写成user.userName形式。如:

<%@ 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">

<%@ taglib prefix="s" uri="/struts-tags"%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

</head>

<body>
<%=request.getParameter("user.userName")%>登录成功,欢迎您!<br/>
<s:property value="user.userName"/>登录成功,欢迎您!<br/>

</body>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐