SpringMVC学习笔记一

来源:互联网 发布:深圳市网络夏令营 编辑:程序博客网 时间:2024/06/04 19:40

表单
1.Spring标签库form的使用需要后台控制器初始化DTO对象,一般默认对象为command

controller内对应初始化方法内,需要在模型内加入command对象

return new ModelAndView("xxxx", "command", new Student());//orreturn new ModelAndView("student", "insertDTO", new Student());

与jsp页面内modelAttribute名称保持一致

<form:form method="POST" modelAttribute="insertDTO" action="/student/addStudent">

该表单对应的提交方法中ModelAttribute参数值也需保持一致

public String addStudent(@ModelAttribute("insertDTO")Student student, ModelMap model){

2.SpringMVC访问静态资源
dispatcher-servlet中,可以使用Web容器的default servlet处理,也可以使用mvc:default-servlet-handler处理静态资源。采用注解。具体内容百度。

0 0
原创粉丝点击