zoukankan      html  css  js  c++  java
  • SpringMVC 接收表单数据的方式

    1.@RequestParam

    1     @RequestMapping(value = "/xxxx.do")  
    2     public void create(@RequestParam(value="userName") String userName) throws Exception {  
    3           
    4     }  


    2.@PathVariable

    1     @RequestMapping(value="/{groupId}.do")  
    2     public void detail(@PathVariable long groupId){  
    3         groupRepository.selectOne(groupId);  
    4     }  

    @ModelAttribute

    1     @RequestMapping(value = "/xxxx.do")  
    2     public String create(@ModelAttribute User user) throws Exception {  
    3         userService.insert(user);  
    4         return "redirect:/user/create.do";  
    5     }  

    4.Request对象

    1     public ModelAndView method1(HttpServletRequest request,  
    2                HttpServletResponse respnose) throws ServletException, IOException {  
    3            Map model = new HashMap();  
    4            model.put("message", "你调用的是方法1");  
    5             return new ModelAndView("/index.jsp", "model", model);  
    6      }  
  • 相关阅读:
    Linux之nginx服务
    设计模式-总结
    linux rabbitmq 远程登录
    swagger常用注解
    nginx总结
    mysql-sql
    dubbo-文档
    JVM总结-Java语法糖与Java编译器
    JVM总结-synchronized
    JVM总结-java内存模型
  • 原文地址:https://www.cnblogs.com/sharpest/p/5730900.html
Copyright © 2011-2022 走看看