日期:2014-05-19  浏览次数:20659 次

struts2 无法接收参数
我使用了struts2 spring和hibernate整合一个功能模块,但在提交表单时,struts2无法接收到表单传递过来的参数,这个问题已经困扰了我一天了,请高手指点。。。。
表单如下:[size=16px][/size]<body>
<s:form theme="simple" action="booksAction_addBook" method="get">
<table align="center" width="100%">
<tr>
<th colspan="2">
增加书箱
</th>
</tr>
<tr>
<td>
书名
</td>
<td>
<s:textfield name="books.bookName"></s:textfield>
</td>
</tr>
<tr>
<td>
库存
</td>
<td>
<s:textfield name="books.count"></s:textfield>
</td>
</tr>
<tr>
<td>
单价
</td>
<td>
<s:textfield name="books.price"></s:textfield>
</td>
</tr>
<tr>
<td>
目录
</td>
<td>
<%

CKEditorConfig settings = new CKEditorConfig();
settings.addConfigValue("width", "900px");
request.setAttribute("settings", settings);
%>

<ckeditor:editor config="<%=settings %>" editor="books.content"
basePath="ckeditor/"></ckeditor:editor>
</td>
</tr>
<tr>
<td>
描述
</td>
<td>

<textarea rows="10" cols="90" name="books.description"
id="books.description"></textarea>
</td>
</tr>
<tr>
<td>
时间
</td>
<td>
<s:textfield name="books.dt"></s:textfield>
</td>
</tr>
<tr>
<td clospan="2">
<s:submit value="添加" theme="simple"></s:submit>
</td>
</tr>
</table>
</s:form>

<ckeditor:replace replace="books.description" config="${settings }"
basePath="ckeditor/"></ckeditor:replace>
</body>
Action如下:
public class BooksAction extends ActionSupport implements RequestAware {

private Books books;

public String addBook() throws Exception {
System.out.println("添加="+books);
return index();
}
}

Books对象实体如下:
package com.yier.entity;

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;

/**
 * Books entity. @author MyEclipse Persistence Tools
 */

public class Books implements java.io.Serializable {

// Fields

/**

*/
private static final long serialVersionUID = 1L;
private long id;
private String bookName;
private long count;
private String price;
private String content;
private String description;
private Date dt;

// Constructors

/** default constructor */
public Books() {
}

/** full constructor */
public Books(String bookname, long count, String price,
String content, String description, Date dt) {
this.bookName = bookname;
this.count = count;
this.price = price;
this.content = content;
this.description = description;
this.dt