ssh框架action域模型不起作用,接收不到jsp页面传来的id值
2014-04-26 15:48
423 查看
在用myeclipse做毕业设计的时候,我想要在jsp页面向action跳转的时候,传数据id的值到action里,再用域模型接收。jsp里面的id有值,但是action里面获取id的那一行会报错:空指针异常;查找了好久发现是我在action里面定义的域模型对象的变量名无法生成get方法,只能生成set方法,具体为什么我也不知道,还希望高手可以指点。把变量名改一下,再生成get、set方法就可以了。下面是我的例子。
jsp页面:
<td style="text-align: center">
<a id="add_dialog" href="MyEngLearn/frame/getWelnews.action?welnews.id=${wn.id}">查看精彩内容</a>
</td>
action页面:
private Welnews welnews;
public void setWelnews(Welnews welnews) {
this.welnews = welnews;
}
public String getWelnews()
{
int id=welnews.getId();
Welnews wn=welnewsservice.getWelnewsById(id);
this.put2Session("wn", wn);
return "getWelnews";
}
welnews对象不能生成get方法,因而域模型不起作用,得不到前台传来的id值。把welnews改成welnew就,再生成get、set方法就可以了。
jsp页面:
<td style="text-align: center">
<a id="add_dialog" href="MyEngLearn/frame/getWelnews.action?welnew.id=${wn.id}">查看精彩内容</a>
</td>
action页面:
private Welnews welnew;
public Welnews getWelnew() {
return welnew;
}
public void setWelnew(Welnews welnew) {
this.welnew = welnew;
}
public String templateFrame()
{
PageModel<Welnews> pm=welnewsservice.ListWelnews(pageNo, pageSize);
this.put2Session("recordCount", pm.getRecordCount());
this.put2Session("pageNo", pm.getPageNo());
this.put2Session("pageSize", pm.getPageSize());
this.put2Session("data", pm.getData());
return "template";
}
jsp页面:
<td style="text-align: center">
<a id="add_dialog" href="MyEngLearn/frame/getWelnews.action?welnews.id=${wn.id}">查看精彩内容</a>
</td>
action页面:
private Welnews welnews;
public void setWelnews(Welnews welnews) {
this.welnews = welnews;
}
public String getWelnews()
{
int id=welnews.getId();
Welnews wn=welnewsservice.getWelnewsById(id);
this.put2Session("wn", wn);
return "getWelnews";
}
welnews对象不能生成get方法,因而域模型不起作用,得不到前台传来的id值。把welnews改成welnew就,再生成get、set方法就可以了。
jsp页面:
<td style="text-align: center">
<a id="add_dialog" href="MyEngLearn/frame/getWelnews.action?welnew.id=${wn.id}">查看精彩内容</a>
</td>
action页面:
private Welnews welnew;
public Welnews getWelnew() {
return welnew;
}
public void setWelnew(Welnews welnew) {
this.welnew = welnew;
}
public String templateFrame()
{
PageModel<Welnews> pm=welnewsservice.ListWelnews(pageNo, pageSize);
this.put2Session("recordCount", pm.getRecordCount());
this.put2Session("pageNo", pm.getPageNo());
this.put2Session("pageSize", pm.getPageSize());
this.put2Session("data", pm.getData());
return "template";
}
相关文章推荐
- action传list到jsp页面,js接收并解析list(struts2中)
- jsp页面传值到action,命名name,对象自动接收
- struts2后台Action接收jsp页面的值
- struts2 action中获取不到从jsp页面提交过来的bean
- jsp a标签传值到action中,action接收不到传值
- 关于用struts2框架中iframe对应的jsp页面的不到action的值的问题
- JSP页面结合Struts2如何传递复选框对应的id数组到后台action中
- Action如何接收jsp页面form表单提交的数据?
- 在jsp页面用request.setAttribute()在action用request.getAttribute()接收得到为null的问题的解决方法
- action接收jsp页面的数据
- Action从jsp页面取值的<input id="user.pid",name="user.pid" value="huang">
- jsp页面ajax接收不到json值报406
- 用struts2框架中iframe对应的jsp页面的不到action的值
- Struts2 后台action接收 jsp页面中checkbox中的值
- action接收到来自jsp页面的请求时出现中文乱码问题处理方法
- Action如何接收jsp页面form表单提交的数据?
- ssh框架总结action接收参数的三种方式页面访问的方式
- 怎么将JSP页面的ID值传给Action进行更新和删除
- jsp页面获取不到servlet中添加到request中的信息问题详解
- jsp页面 URL传中文参数到Action里面出现乱码,用过滤器和控制器都解决