spring-mvc中bean的使用

http://blog.csdn.net/z69183787/article/details/41653875
http://blog.csdn.net/z69183787/article/details/41653843
http://blog.163.com/leizongxiang@126/blog/static/36845004201002051715512/
http://hw1287789687.iteye.com/blog/1950237
http://yunzhu.iteye.com/blog/2088548


@Controller
@RequestMapping("/testdemo")
public class TestController {

	@RequestMapping(value="intoTest")
	public String intoTest(HttpServletRequest request){
		return "recommend/test";
	}
	
	@RequestMapping(value="saveTest")
//	@ResponseBody
	public String saveinfo(HttpServletRequest request,FormBean bean){
		System.out.println(bean.getTestId());
		return "recommend/test";
	}
}

public class FormBean {  
  
    private String testId;  
      
    private String testName;  
      
    public String getTestId() {  
        return testId;  
    }  
  
    public void setTestId(String testId) {  
        this.testId = testId;  
    }  
  
    public String getTestName() {  
        return testName;  
    }  
  
    public void setTestName(String testName) {  
        this.testName = testName;  
    }    
} 

recommend/test.jsp

<form id="testForm" name="testForm" method="post" action="${base}/testdemo/saveTest.do">
 		<table>
 			<tr>
 				<td>ID号:</td>
 				<td><input id="testId" name="testId"></td>
 			</tr>
 			<tr>
 				<td>名称:</td>
 				<td><input id="testName" name="testName"></td>
 			</tr>
 			<tr>
 				<td><input type="submit" value="submit">
 				</td>
 			</tr>
 		</table>
 	</form>

你可能感兴趣的:(spring-mvc中bean的使用)