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

错误提示:

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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值