当前位置: 代码迷 >> Java Web开发 >> struts2 form交付对象有的接收过来是null呢
  详细解决方案

struts2 form交付对象有的接收过来是null呢

热度:8017   发布时间:2013-02-25 21:14:14.0
struts2 form提交对象有的接收过来是null呢?
<%@ page language="java" contentType="text/html; charset=utf-8"%>  
<%@ taglib prefix="s" uri="/struts-tags" %>  
<html>  
<head>  
<title>Insert title here</title>  
</head>  
<body>  
<form action="add.action" method="post" name="form1">
<input type="text" name="book.name"/>
<input type="text" name="book.author"/>
<input type="text" name="book.price"/>
<input type="submit">
</form>  
</body>  
</html>  

传到后台private Book book 里
只有price有值,name,author都为null,是咋回事呢.get set都有的?

------解决方案--------------------------------------------------------
把你book类贴出来看哈
------解决方案--------------------------------------------------------
你确定你book的属性没写错?
------解决方案--------------------------------------------------------
你可以先试一下那个属性传值的方法。。。如果还不行的话,那就是要重新把你的工程的流程看一下。。
------解决方案--------------------------------------------------------
<form action="add.action" method="post" name="form1">
<input type="text" name="book.name"/>
<input type="text" name="book.author"/>
<input type="text" name="book.price"/>
<input type="submit">
</form>
只是struts2的表单?
<s:form></s:form>.....
------解决方案--------------------------------------------------------
应该用struts2的表单<s:form></s:form>,然后在action写set和get方法,普通的表单不行!
------解决方案--------------------------------------------------------
在把你action的代码贴出来
  相关解决方案