Java 类org.springframework.web.bind.annotation.MatrixVariable 实例源码

项目:MathMLCanEval    文件:UserController.java   
@RequestMapping(value={"/list/{filters}","/list/{filters}/"},method = RequestMethod.GET)
@SiteTitle("{navigation.user.list}")
public ModelAndView filterList(@MatrixVariable(pathVar = "filters") Map<String,List<String>> filters)
{
    ModelMap mm = new ModelMap();

    if(filters.containsKey("role_name"))
    {
        mm.addAttribute("userList", userService.getUsersByRole(userRoleService.getUserRoleByName(filters.get("role_name").get(0))));
    }
    else
    {
        mm.addAttribute("userList", userService.getAllUsers());
    }

    return new ModelAndView("user_list",mm);
}
项目:MathMLCanEval    文件:ProgramController.java   
@RequestMapping(value = {"/list/{filters}","/list/{filters}/"},method = RequestMethod.GET)
@SiteTitle("{navigation.program.list}")
public ModelAndView filterList(@MatrixVariable(pathVar = "filters") Map<String,List<String>> filters)
{
    ModelMap mm = new ModelMap();
    if(filters.containsKey("name") && filters.containsKey("version"))
    {
        mm.addAttribute("programList", 
                programService.getProgramByNameAndVersion(filters.get("name").get(0), filters.get("version").get(0)));
    }
    else
    {
        mm.addAttribute("programList", programService.getAllPrograms());
    }

    return new ModelAndView("program_list",mm);
}
项目:MathMLCanEval    文件:CanonicOutputController.java   
@RequestMapping(value = {"/list/{filters}","/list/{filters}/"},method = RequestMethod.GET)
public ModelAndView filterList(@MatrixVariable(pathVar = "filters") Map<String,List<String>> filters, @ModelAttribute("pagination") Pagination pagination)
{
    ModelMap mm = new ModelMap();
    if(filters.containsKey("apprun"))
    {
        ApplicationRun applicationRun = applicationRunService.getApplicationRunByID(Long.valueOf(filters.get("apprun").get(0)));
        SearchResponse<CanonicOutput> result = canonicOutputService.getCanonicOutputByAppRun(applicationRun, pagination);
        pagination.setNumberOfRecords(result.getTotalResultSize());
        mm.addAttribute("pagination", pagination);
        mm.addAttribute("outputList", result.getResults());
    }
    else
    {
        mm.addAttribute("outputList", ListUtils.EMPTY_LIST);
    }

    return new ModelAndView("canonicoutput_list",mm);
}
项目:spring4-understanding    文件:MatrixVariableMapMethodArgumentResolver.java   
@Override
public boolean supportsParameter(MethodParameter parameter) {
    MatrixVariable matrixVariable = parameter.getParameterAnnotation(MatrixVariable.class);
    if (matrixVariable != null) {
        if (Map.class.isAssignableFrom(parameter.getParameterType())) {
            return !StringUtils.hasText(matrixVariable.name());
        }
    }
    return false;
}
项目:spring4-understanding    文件:MatrixVariableMethodArgumentResolver.java   
@Override
public boolean supportsParameter(MethodParameter parameter) {
    if (!parameter.hasParameterAnnotation(MatrixVariable.class)) {
        return false;
    }
    if (Map.class.isAssignableFrom(parameter.getParameterType())) {
        String variableName = parameter.getParameterAnnotation(MatrixVariable.class).name();
        return StringUtils.hasText(variableName);
    }
    return true;
}
项目:spring4-understanding    文件:UriTemplateServletAnnotationControllerHandlerMethodTests.java   
@RequestMapping("/{root}")
public void handle(@PathVariable("root") int root, @MatrixVariable(required=false, defaultValue="7") int q,
        Writer writer) throws IOException {

    assertEquals("Invalid path variable value", 42, root);
    writer.write("test-" + root + "-" + q);
}
项目:spring4-understanding    文件:UriTemplateServletAnnotationControllerHandlerMethodTests.java   
@RequestMapping("/hotels/{hotel}/bookings/{booking}-{other}")
public void handle(@PathVariable("hotel") String hotel,
        @PathVariable int booking,
        @PathVariable String other,
        @MatrixVariable(name = "q", pathVar = "hotel") int qHotel,
        @MatrixVariable(name = "q", pathVar = "other") int qOther,
        Writer writer) throws IOException {
    assertEquals("Invalid path variable value", "42", hotel);
    assertEquals("Invalid path variable value", 21, booking);
    writer.write("test-" + hotel + "-q" + qHotel + "-" + booking + "-" + other + "-q" + qOther);
}
项目:spring4-understanding    文件:UriTemplateServletAnnotationControllerHandlerMethodTests.java   
@RequestMapping("/hotels/{hotel}/bookings/{booking}-{other}")
public void handle(@PathVariable("hotel") String hotel, @PathVariable int booking,
        @PathVariable String other, @MatrixVariable MultiValueMap<String, String> params) {

    assertEquals("Invalid path variable value", "42", hotel);
    assertEquals("Invalid path variable value", 21, booking);
    assertEquals(Arrays.asList("1", "2", "3"), params.get("q"));
    assertEquals("R", params.getFirst("r"));
}
项目:spring4-understanding    文件:UriTemplateServletAnnotationControllerHandlerMethodTests.java   
@RequestMapping("/{root:\\d+}{params}")
public void handle(@PathVariable("root") int root, @PathVariable("params") String paramString,
        @MatrixVariable List<Integer> q, Writer writer) throws IOException {

    assertEquals("Invalid path variable value", 42, root);
    writer.write("test-" + root + "-" + paramString + "-" + q);
}
项目:spring4-understanding    文件:MatrixVariablesMapMethodArgumentResolverTests.java   
public void handle(
        String stringArg,
        @MatrixVariable Map<String, String> map,
        @MatrixVariable MultiValueMap<String, String> multivalueMap,
        @MatrixVariable(pathVar="cars") MultiValueMap<String, String> mapForPathVar,
        @MatrixVariable("name") Map<String, String> mapWithName) {
}
项目:elasticSearchKata    文件:CrudController.java   
@RequestMapping(value = "/{id:\\d+}", method = RequestMethod.GET)
public ResponseEntity<?> getResourceById(@PathVariable("id") K id, @MatrixVariable Optional<Map<String, String>> maps) {
    log.info("+++  getResourceById {}", id);
    T item = service.findById(id);
    //if(maps.isPresent()){
      log.info("+++++       id={} , matrixVars={} ", id, maps);
   // }

    return getRightResponseEntity(item);
}
项目:spring-profile    文件:FileUploadController.java   
@RequestMapping(
        value = "{path}/invoice",
        method = RequestMethod.POST
)
@ResponseBody
public HttpEntity invoice(
        @PathVariable String path,
        @MatrixVariable(value = "refNo", pathVar = "path") String referenceNumber,
        @RequestParam(value = "image", required = true) List<MultipartFile> files
) throws IOException {
    System.out.println(path);
    System.out.println(files);
    return ResponseEntity.ok("{\"state\": \"All Well\"}");
}
项目:s_framework    文件:DemoController.java   
/**
 * URL template pattern -- Work with matrix
 * GET /teacher/1018110323;name=lihe;age=18
 * @param day
 * @param model
 * @return
 */
@RequestMapping(value="/teacher/{userId}", method = RequestMethod.GET)
public String matrix(@PathVariable String userId
        , @MatrixVariable(value="name",defaultValue="joe") String theName
        , @MatrixVariable int age, Model model) {
   model.addAttribute("username",theName);
   model.addAttribute("age",age);
    return "main";
}
项目:s_framework    文件:DemoController.java   
/**
 * URL template pattern -- Work with matrix -- advanced
 * matrix can also be obtained in a map.
 * 
 * GET /teacher/1018110323;name=lihe/18;fakeAge=25
 * @param day
 * @param model
 * @return
 */
@RequestMapping(value="/teacher/{userId}/{age}", method = RequestMethod.GET)
public String matrixAdvanced(@PathVariable String userId
        , @PathVariable int age
        , @MatrixVariable(value="name", pathVar="userId") String theName
        , @MatrixVariable(pathVar="age") int fakeAge, Model model) {
   model.addAttribute("username",theName);
   model.addAttribute("age",fakeAge);
    return "main";
}
项目:class-guard    文件:MatrixVariableMapMethodArgumentResolver.java   
public boolean supportsParameter(MethodParameter parameter) {
    MatrixVariable paramAnnot = parameter.getParameterAnnotation(MatrixVariable.class);
    if (paramAnnot != null) {
        if (Map.class.isAssignableFrom(parameter.getParameterType())) {
            return !StringUtils.hasText(paramAnnot.value());
        }
    }
    return false;
}
项目:class-guard    文件:MatrixVariableMethodArgumentResolver.java   
public boolean supportsParameter(MethodParameter parameter) {
    if (!parameter.hasParameterAnnotation(MatrixVariable.class)) {
        return false;
    }
    if (Map.class.isAssignableFrom(parameter.getParameterType())) {
        String paramName = parameter.getParameterAnnotation(MatrixVariable.class).value();
        return StringUtils.hasText(paramName);
    }
    return true;
}
项目:class-guard    文件:UriTemplateServletAnnotationControllerHandlerMethodTests.java   
@RequestMapping("/{root}")
public void handle(@PathVariable("root") int root, @MatrixVariable(required=false, defaultValue="7") int q,
        Writer writer) throws IOException {

    assertEquals("Invalid path variable value", 42, root);
    writer.write("test-" + root + "-" + q);
}
项目:class-guard    文件:UriTemplateServletAnnotationControllerHandlerMethodTests.java   
@RequestMapping("/hotels/{hotel}/bookings/{booking}-{other}")
public void handle(@PathVariable("hotel") String hotel,
        @PathVariable int booking,
        @PathVariable String other,
        @MatrixVariable(value="q", pathVar="hotel") int qHotel,
        @MatrixVariable(value="q", pathVar="other") int qOther,
        Writer writer) throws IOException {
    assertEquals("Invalid path variable value", "42", hotel);
    assertEquals("Invalid path variable value", 21, booking);
    writer.write("test-" + hotel + "-q" + qHotel + "-" + booking + "-" + other + "-q" + qOther);
}
项目:class-guard    文件:UriTemplateServletAnnotationControllerHandlerMethodTests.java   
@RequestMapping("/hotels/{hotel}/bookings/{booking}-{other}")
public void handle(@PathVariable("hotel") String hotel, @PathVariable int booking,
        @PathVariable String other, @MatrixVariable MultiValueMap<String, String> params) {

    assertEquals("Invalid path variable value", "42", hotel);
    assertEquals("Invalid path variable value", 21, booking);
    assertEquals(Arrays.asList("1", "2", "3"), params.get("q"));
    assertEquals("R", params.getFirst("r"));
}
项目:class-guard    文件:UriTemplateServletAnnotationControllerHandlerMethodTests.java   
@RequestMapping("/{root:\\d+}{params}")
public void handle(@PathVariable("root") int root, @PathVariable("params") String paramString,
        @MatrixVariable List<Integer> q, Writer writer) throws IOException {

    assertEquals("Invalid path variable value", 42, root);
    writer.write("test-" + root + "-" + paramString + "-" + q);
}
项目:class-guard    文件:MatrixVariablesMapMethodArgumentResolverTests.java   
public void handle(
        String stringArg,
        @MatrixVariable Map<String, String> map,
        @MatrixVariable MultiValueMap<String, String> multivalueMap,
        @MatrixVariable(pathVar="cars") MultiValueMap<String, String> mapForPathVar,
        @MatrixVariable("name") Map<String, String> mapWithName) {
}
项目:spring-cloud-netflix    文件:RestClientRibbonCommandIntegrationTests.java   
@RequestMapping("/matrix/{name}/{another}")
public String matrix(@PathVariable("name") String name,
        @MatrixVariable(value = "p", pathVar = "name") int p,
        @MatrixVariable(value = "q", pathVar = "name") int q,
        @PathVariable("another") String another,
        @MatrixVariable(value = "x", pathVar = "another") int x) {
    return name + "=" + p + "-" + q + ";" + another + "=" + x;
}
项目:spring4-understanding    文件:MatrixVariableMethodArgumentResolver.java   
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
    MatrixVariable annotation = parameter.getParameterAnnotation(MatrixVariable.class);
    return new MatrixVariableNamedValueInfo(annotation);
}
项目:spring4-understanding    文件:MatrixVariableMethodArgumentResolver.java   
@Override
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request) throws Exception {

    @SuppressWarnings("unchecked")
    Map<String, MultiValueMap<String, String>> pathParameters =
        (Map<String, MultiValueMap<String, String>>) request.getAttribute(
                HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);

    if (CollectionUtils.isEmpty(pathParameters)) {
        return null;
    }

    String pathVar = parameter.getParameterAnnotation(MatrixVariable.class).pathVar();
    List<String> paramValues = null;

    if (!pathVar.equals(ValueConstants.DEFAULT_NONE)) {
        if (pathParameters.containsKey(pathVar)) {
            paramValues = pathParameters.get(pathVar).get(name);
        }
    }
    else {
        boolean found = false;
        paramValues = new ArrayList<String>();
        for (MultiValueMap<String, String> params : pathParameters.values()) {
            if (params.containsKey(name)) {
                if (found) {
                    String paramType = parameter.getParameterType().getName();
                    throw new ServletRequestBindingException(
                            "Found more than one match for URI path parameter '" + name +
                            "' for parameter type [" + paramType + "]. Use pathVar attribute to disambiguate.");
                }
                paramValues.addAll(params.get(name));
                found = true;
            }
        }
    }

    if (CollectionUtils.isEmpty(paramValues)) {
        return null;
    }
    else if (paramValues.size() == 1) {
        return paramValues.get(0);
    }
    else {
        return paramValues;
    }
}
项目:spring4-understanding    文件:MatrixVariableMethodArgumentResolver.java   
private MatrixVariableNamedValueInfo(MatrixVariable annotation) {
    super(annotation.name(), annotation.required(), annotation.defaultValue());
}
项目:spring4-understanding    文件:MatrixVariablesMethodArgumentResolverTests.java   
public void handle(
        String stringArg,
        @MatrixVariable List<String> colors,
        @MatrixVariable(name = "year", pathVar = "cars", required = false, defaultValue = "2013") int preferredYear) {
}
项目:mvc    文件:ProductController.java   
@RequestMapping("/filter/{ByCriteria}")
public String getProductsByFilter(@MatrixVariable(pathVar = "ByCriteria") Map<String, List<String>> filterParams, Model model) {
    model.addAttribute("products", productService.getProductsByFilter(filterParams));
    return "products";
}
项目:class-guard    文件:MatrixVariableMethodArgumentResolver.java   
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
    MatrixVariable annotation = parameter.getParameterAnnotation(MatrixVariable.class);
    return new PathParamNamedValueInfo(annotation);
}
项目:class-guard    文件:MatrixVariableMethodArgumentResolver.java   
@Override
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request) throws Exception {

    @SuppressWarnings("unchecked")
    Map<String, MultiValueMap<String, String>> pathParameters =
        (Map<String, MultiValueMap<String, String>>) request.getAttribute(
                HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);

    if (CollectionUtils.isEmpty(pathParameters)) {
        return null;
    }

    String pathVar = parameter.getParameterAnnotation(MatrixVariable.class).pathVar();
    List<String> paramValues = null;

    if (!pathVar.equals(ValueConstants.DEFAULT_NONE)) {
        if (pathParameters.containsKey(pathVar)) {
            paramValues = pathParameters.get(pathVar).get(name);
        }
    }
    else {
        boolean found = false;
        paramValues = new ArrayList<String>();
        for (MultiValueMap<String, String> params : pathParameters.values()) {
            if (params.containsKey(name)) {
                if (found) {
                    String paramType = parameter.getParameterType().getName();
                    throw new ServletRequestBindingException(
                            "Found more than one match for URI path parameter '" + name +
                            "' for parameter type [" + paramType + "]. Use pathVar attribute to disambiguate.");
                }
                paramValues.addAll(params.get(name));
                found = true;
            }
        }
    }

    if (CollectionUtils.isEmpty(paramValues)) {
        return null;
    }
    else if (paramValues.size() == 1) {
        return paramValues.get(0);
    }
    else {
        return paramValues;
    }
}
项目:class-guard    文件:MatrixVariableMethodArgumentResolver.java   
private PathParamNamedValueInfo(MatrixVariable annotation) {
    super(annotation.value(), annotation.required(), annotation.defaultValue());
}
项目:class-guard    文件:MatrixVariablesMethodArgumentResolverTests.java   
public void handle(
        String stringArg,
        @MatrixVariable List<String> colors,
        @MatrixVariable(value="year", pathVar="cars", required=false, defaultValue="2013") int preferredYear) {
}
项目:maven-framework-project    文件:ProductController.java   
@RequestMapping("/filter/{ByCriteria}")
public String getProductsByFilter(@MatrixVariable(pathVar="ByCriteria") Map<String,List<String>> filterParams, Model model) {
    model.addAttribute("products", productService.getProductsByFilter(filterParams));
    return "products";
}
项目:maven-framework-project    文件:ProductController.java   
@RequestMapping("/filter/{ByCriteria}")
public String getProductsByFilter(@MatrixVariable(pathVar="ByCriteria") Map<String,List<String>> filterParams, Model model) {
    model.addAttribute("products", productService.getProductsByFilter(filterParams));
    return "products";
}
项目:maven-framework-project    文件:ProductController.java   
@RequestMapping("/filter/{ByCriteria}")
public String getProductsByFilter(@MatrixVariable(pathVar="ByCriteria") Map<String,List<String>> filterParams, Model model) {
    model.addAttribute("products", productService.getProductsByFilter(filterParams));
    return "products";
}
项目:maven-framework-project    文件:ProductController.java   
@RequestMapping("/filter/{ByCriteria}")
public String getProductsByFilter(@MatrixVariable(pathVar="ByCriteria") Map<String,List<String>> filterParams, Model model) {
    model.addAttribute("products", productService.getProductsByFilter(filterParams));
    return "products";
}
项目:maven-framework-project    文件:ProductController.java   
@RequestMapping("/filter/{ByCriteria}")
public String getProductsByFilter(@MatrixVariable(pathVar="ByCriteria") Map<String,List<String>> filterParams, Model model) {
    model.addAttribute("products", productService.getProductsByFilter(filterParams));
    return "products";
}
项目:maven-framework-project    文件:ProductController.java   
@RequestMapping("/filter/{ByCriteria}")
public String getProductsByFilter(@MatrixVariable(pathVar="ByCriteria") Map<String,List<String>> filterParams, Model model) {
    model.addAttribute("products", productService.getProductsByFilter(filterParams));
    return "products";
}
项目:maven-framework-project    文件:ProductController.java   
@RequestMapping("/filter/{ByCriteria}")
public String getProductsByFilter(@MatrixVariable(pathVar="ByCriteria") Map<String,List<String>> filterParams, Model model) {
    model.addAttribute("products", productService.getProductsByFilter(filterParams));
    return "products";
}
项目:maven-framework-project    文件:ProductController.java   
@RequestMapping("/filter/{ByCriteria}")
public String getProductsByFilter(@MatrixVariable(pathVar="ByCriteria") Map<String,List<String>> filterParams, Model model) {
    model.addAttribute("products", productService.getProductsByFilter(filterParams));
    return "products";
}
项目:maven-framework-project    文件:ProductController.java   
@RequestMapping("/filter/{ByCriteria}")
public String getProductsByFilter(@MatrixVariable(pathVar="ByCriteria") Map<String,List<String>> filterParams, Model model) {
    model.addAttribute("products", productService.getProductsByFilter(filterParams));
    return "products";
}