zoukankan      html  css  js  c++  java
  • SSM notes

      spring mvc中的@PathVariable是用来获得请求url中的动态参数的,十分方便,复习下: 
    
    Java代码  收藏代码
    @Controller  
    public class TestController {  
         @RequestMapping(value="/user/{userId}/roles/{roleId}",method = RequestMethod.GET)  
         public String getLogin(@PathVariable("userId") String userId,  
             @PathVariable("roleId") String roleId){  
             System.out.println("User Id : " + userId);  
             System.out.println("Role Id : " + roleId);  
             return "hello";  
         }  
         @RequestMapping(value="/product/{productId}",method = RequestMethod.GET)  
         public String getProduct(@PathVariable("productId") String productId){  
               System.out.println("Product Id : " + productId);  
               return "hello";  
         }  
         @RequestMapping(value="/javabeat/{regexp1:[a-z-]+}",  
               method = RequestMethod.GET)  
         public String getRegExp(@PathVariable("regexp1") String regexp1){  
               System.out.println("URI Part 1 : " + regexp1);  
               return "hello";  
         }  
    }  

    required

    Whether the parameter is required.

    是否需要参数。

    Default is true, leading to an exception thrown in case of the parameter missing in the request. Switch this to false if you prefer a null in case of the parameter missing.

    默认为true,若请求中没有参数会导致抛出一个异常。若设置为false,若请求中没有参数就会返回null。

    Alternatively, provide a defaultValue, which implicitly sets this flag to false.

    required=false时,最好设置一个defaultValue默认值。

    @RequestParam(value = "abc",required=false)

  • 相关阅读:
    在 ML2 中 enable local network
    实践 Neutron 前的两个准备工作
    配置 linux-bridge mechanism driver
    为 Neutron 准备物理基础设施(II)
    两张图总结 Neutron 架构
    Service Plugin / Agent
    详解 ML2 Core Plugin(I)
    #define用法集锦[修正版]
    socketpair理解
    判断单链表是否存在环,判断两个链表是否相交-的相关讨论
  • 原文地址:https://www.cnblogs.com/chenyedev/p/7337276.html
Copyright © 2011-2022 走看看