package com.cola.struts;
import com.cola.bean.Book;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
@SuppressWarnings("all")
public class UserAction extends ActionSupport implements ModelDriven<Book> {
private Book book;
/*
* public String list(){ System.out.println(
* "User‘s list-------------------->"); return "success"; }
*/
public String execute() {
System.out.println(book);
return null;
}
public Book getBook() {
return book;
}
@Override
public Book getModel() {
if (book == null) {
book = new Book();
}
return book;
}
public void setBook(Book book) {
this.book = book;
}
}
< form action= "user" method = "get">
bookname: < input name= "bookname" /><br />
bookauthor:< input name= "bookauthor" /><br />
bookprice: < input name= "bookprice" /><br />
<input type = "submit" value= "add"/>< br/>
</ form>
原文地址:http://icola.blog.51cto.com/5412204/1721692