SpingMVC ModelAttribute的用法

@Controller
@RequestMapping(value = "/test")
public class TestController {
    @RequestMapping("/addUser")
    public void addUser(@ModelAttribute(value = "adminUser") AdminUser adminUser, Writer writer) throws IOException {
        System.out.println("adminUser = " + adminUser);
        writer.write("successfully");
    }

    @RequestMapping("/addUser2")
    public void addUser2(AdminUser adminUser2, Writer writer) throws IOException {
        System.out.println("adminUser2 = " + adminUser2);
        writer.write("successfully2");
    }
}


两种写法都能达到一样的效果。

posted @ 2014-05-20 19:38  无忧之路  阅读(358)  评论(0编辑  收藏  举报
无忧之路