例如:
<formaction="submitall.do"method="post">
<div>姓名:div>
<div><input name="name" value="zzz"/>div>
<div>div>
<div>年龄:div>
<div><input name="age" value="55"/>div>
<div>兴趣:div>
<div>
<inputtype="checkbox"name="interests"value="听歌"checked="checked"/>听歌
<inputtype="checkbox"name="interests"value="书法"checked="checked"/>书法
<inputtype="checkbox"name="interests"value="看电影"/>看电影
div>
<divclass="clear">div>
<div><inputtype="submit"value="提交表单"/>div>
form>
@RequestMapping("/submitall")
public void login(String name, Integerage, Double income, BooleanisMarried,
String[]interests){
System.out.println("简单数据类型绑定=========");
System.out.println("名字:" +name);
System.out.println("年龄:" +age);
System.out.println("兴趣:");
for (Stringinterest : interests)
{
System.out.println(interest);
}
System.out.println("====================");
}
package com.test.entity;
import java.io.Serializable;
import javax.persistence.*;
importorg.hibernate.annotations.GenericGenerator;
/**
*The persistent class for the book database table.
*
*/
@Entity
@Table(name="book")
public class Book implements Serializable {
privatestatic final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name ="system-uuid",strategy="uuid")
@Column
privateint id;
@Column
private String auther;
@Column
private String bookname;
@Column
private String isbn;
@Column
private int price;
@Column
private int stock;
publicBook() {
}
publicint getId() {
returnthis.id;
}
publicvoid setId(int id) {
this.id= id;
}
publicString getAuther() {
returnthis.auther;
}
publicvoid setAuther(String auther) {
this.auther= auther;
}
publicString getBookname() {
returnthis.bookname;
}
publicvoid setBookname(String bookname) {
this.bookname= bookname;
}
publicString getIsbn() {
returnthis.isbn;
}
publicvoid setIsbn(String isbn) {
this.isbn= isbn;
}
publicint getPrice() {
returnthis.price;
}
publicvoid setPrice(int price) {
this.price= price;
}
publicint getStock() {
returnthis.stock;
}
publicvoid setStock(int stock) {
this.stock= stock;
}
}
<formaction="<%=basePath%>book/updatebook.do"name="Form"
method="post">
<inputtype="hidden"name="id"value="${book.id }">
书名:<inputtype="text"name="bookname"value="${book.bookname}"/>
作者:<inputtype="text"name="auther"value="${book.auther}"/>
isbn:<inputtype="text"name="isbn"value="${book.isbn }"/>
单价:<inputtype="text"name="price"value="${book.price }"/>
库存:<inputtype="text"name="stock"value="${book.stock }"/>
<inputtype="submit"value="编辑">
form>
@RequestMapping("/updatebook")
public ModelAndViewupdateBook(Modelmodel,Bookdto){
System.out.println("***Bookname****"+dto.getBookname());
System.out.println("***Auther****"+dto.getAuther());
System.out.println("***Price****"+dto.getPrice());
System.out.println("***Id****"+dto.getId());
System.out.println("***Stock****"+dto.getStock());
// bookManager.updateBook(dto);
return new ModelAndView("success");
}