struts2框架问题
大侠们,我点击<a href="BbssectorAction!list.action">论坛</a>的时候,触发到
package com.news.action;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.news.dao.BbssectorDAO;
import com.news.dao.impl.BbssectorDAOImpl;
import com.news.model.Bbssector;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class BbssectorAction extends ActionSupport{
private int id;
private Bbssector bbssector;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Bbssector getBbssector() {
return bbssector;
}
public void setBbssector(Bbssector bbssector) {
this.bbssector = bbssector;
}
public String execute() throws Exception
{
return SUCCESS;
}
public String list() throws Exception
{
String result="";
BbssectorDAO bbssectorDAO=new BbssectorDAOImpl();
List list=bbssectorDAO.searchAllBbssector();
System.out.println(list);
if(list!=null)
{
ActionContext act=ActionContext.getContext();
Map map=act.getSession();
map.put("sector", list);
result="sector";
}
else
{
result="error";
}
return result;
}
}
struts.xml的配置文件如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="false" />
<constant name="struts.multipart.saveDir" value="/tmp"/>
<package name="default" namespace="/" extends="struts-default">
<action name="BbssectorAction" class="com.news.action.BbssectorAction">
<result name="sector">/sector.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
点击的时候抛出:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)