SSH整合,
空指针异常求助!
异常如下
———————————————————————————————————————
description
The server encountered an internal error () that prevented it from fulfilling this request.exception
java.lang.NullPointerException com.action.DeleteLineAction.execute(DeleteLineAction.java:15)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
———————————————————————————————————————
DeleteLineAction.java 如下:
package com.action;
import com.dao.LineDAO;
import com.opensymphony.xwork2.ActionSupport;
import com.service.ActionManager;
public class DeleteLineAction extends ActionSupport {
private static final long serialVersionUID = 1L;
protected ActionManager mgr;
private LineDAO lineDAO;
private Integer lineId;
public String execute() throws Exception{
System.out.println(1);
Integer temp = mgr.validDeleteLine(lineId);
if(temp!=null){
lineDAO.delete(lineId);
System.out.println(lineId);
return "deleteline_success";
}
else{
addActionError("路线不存在");
return "deleteline_failed";
}
}
public void setMgr(ActionManager mgr) {
this.mgr = mgr;
}
public void setLineDAO(LineDAO lineDAO) {
this.lineDAO = lineDAO;
}
public Integer getLineId() {
return lineId;
}
public void setLineId(Integer lineId) {
this.lineId = lineId;
}
}
————————————————————————————————————————
DeleteLineAction.java 中的mgr和lineDAO,在spring配置文件里都已经注入,lineId由jsp页面注入,想不通哪个变量能为空。
applicationContext.xml 如下:
<bean name="DeleteLine" class="com.action.DeleteLineAction">
<property name="mgr" ref="mgr"></property>
</bean>
————————————————————————————————————————
struts.xml 如下:
<action name="deleteLine" class="DeleteLine">
<result name="deleteline_failed">/lines.jsp</result>
<result name="deleteline_success">/test.jsp</result>
</action>
————————————————————————————————————————
lines.jsp 如下:
<%@ page language="java" pageEncoding="GB2312"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title><s:text name="行车路线管理" /></title>
</head>
<body>
<div align="center">
<h1><font color=blue><s:text name="行车路线管理" /></font></