Struts2 form表单向Action提交数据,跳转正常,但是出现空指针
求大神们解决下,最近做一个Struts2+Hibernate的项目,配置好了所有东西,但是Action跳转传值的时候出现了空指针异常,找了许久不知道具体原因这是我的Str...
求大神们解决下,最近做一个Struts2+Hibernate的项目,配置好了所有东西,但是Action跳转传值的时候出现了空指针异常,找了许久不知道具体原因
这是我的Struts2 文件
<struts>
<package name="reglist" namespace="/yw" extends="struts-default" >
<action name="regadd" class="com.soft.actions.yewuActions" >
<result name="ok">/success.jsp</result>
</action>
</package>
</struts>
Action类
public class yewuActions extends ActionSupport{
private yewu yw;
private yewuDao ywDao;
public yewu getYw() {
return yw;
}
public void setYw(yewu yw) {
this.yw = yw;
}
public String execute(){
try {
ywDao.Addyewu(yw);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("成功了");
return "ok";
}
实体类
private String yewutime;
private String yewulevel;
private String username;
private Integer finalout;
private String tvproject;
private String homephone;
private String telephone;
private String homeadd;
private String workadd;
private String beizhu;
.....getter和setter方法 展开
这是我的Struts2 文件
<struts>
<package name="reglist" namespace="/yw" extends="struts-default" >
<action name="regadd" class="com.soft.actions.yewuActions" >
<result name="ok">/success.jsp</result>
</action>
</package>
</struts>
Action类
public class yewuActions extends ActionSupport{
private yewu yw;
private yewuDao ywDao;
public yewu getYw() {
return yw;
}
public void setYw(yewu yw) {
this.yw = yw;
}
public String execute(){
try {
ywDao.Addyewu(yw);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("成功了");
return "ok";
}
实体类
private String yewutime;
private String yewulevel;
private String username;
private Integer finalout;
private String tvproject;
private String homephone;
private String telephone;
private String homeadd;
private String workadd;
private String beizhu;
.....getter和setter方法 展开
3个回答
展开全部
ywDao这东西是struts2的M层,不实例化怎么搞~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询