org.springframework.web.bind.annotation.MatrixVariable Java Examples
The following examples show how to use
org.springframework.web.bind.annotation.MatrixVariable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CategoryController.java From es with Apache License 2.0 | 6 votes |
@RequestMapping(value = {"select/{selectType}", "select"}, method = RequestMethod.GET) @PageableDefaults(sort = "weight=desc") public String select( Searchable searchable, Model model, @PathVariable(value = "selectType") String selectType, @MatrixVariable(value = "domId", pathVar = "selectType") String domId, @MatrixVariable(value = "domName", pathVar = "selectType", required = false) String domName) { this.permissionList.assertHasViewPermission(); model.addAttribute("selectType", selectType); model.addAttribute("domId", domId); model.addAttribute("domName", domName); super.list(searchable, model); return "showcase/product/category/select"; }
Example #2
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From spring-analysis-note with MIT License | 5 votes |
@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); }
Example #3
Source File: MatrixVariableMapMethodArgumentResolver.java From spring-analysis-note with MIT License | 5 votes |
@Nullable @Override public Object resolveArgumentValue(MethodParameter parameter, BindingContext bindingContext, ServerWebExchange exchange) { Map<String, MultiValueMap<String, String>> matrixVariables = exchange.getAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE); if (CollectionUtils.isEmpty(matrixVariables)) { return Collections.emptyMap(); } MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); MatrixVariable annotation = parameter.getParameterAnnotation(MatrixVariable.class); Assert.state(annotation != null, "No MatrixVariable annotation"); String pathVariable = annotation.pathVar(); if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) { MultiValueMap<String, String> mapForPathVariable = matrixVariables.get(pathVariable); if (mapForPathVariable == null) { return Collections.emptyMap(); } map.putAll(mapForPathVariable); } else { for (MultiValueMap<String, String> vars : matrixVariables.values()) { vars.forEach((name, values) -> { for (String value : values) { map.add(name, value); } }); } } return (isSingleValueMap(parameter) ? map.toSingleValueMap() : map); }
Example #4
Source File: MatrixVariablesMapMethodArgumentResolverTests.java From spring-analysis-note with MIT License | 5 votes |
@SuppressWarnings("unused") 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) { }
Example #5
Source File: MatrixVariableMapMethodArgumentResolver.java From spring-analysis-note with MIT License | 5 votes |
@Override @Nullable public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest request, @Nullable WebDataBinderFactory binderFactory) throws Exception { @SuppressWarnings("unchecked") Map<String, MultiValueMap<String, String>> matrixVariables = (Map<String, MultiValueMap<String, String>>) request.getAttribute( HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST); if (CollectionUtils.isEmpty(matrixVariables)) { return Collections.emptyMap(); } MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); MatrixVariable ann = parameter.getParameterAnnotation(MatrixVariable.class); Assert.state(ann != null, "No MatrixVariable annotation"); String pathVariable = ann.pathVar(); if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) { MultiValueMap<String, String> mapForPathVariable = matrixVariables.get(pathVariable); if (mapForPathVariable == null) { return Collections.emptyMap(); } map.putAll(mapForPathVariable); } else { for (MultiValueMap<String, String> vars : matrixVariables.values()) { vars.forEach((name, values) -> { for (String value : values) { map.add(name, value); } }); } } return (isSingleValueMap(parameter) ? map.toSingleValueMap() : map); }
Example #6
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From spring-analysis-note with MIT License | 5 votes |
@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); }
Example #7
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From spring-analysis-note with MIT License | 5 votes |
@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")); }
Example #8
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From spring-analysis-note with MIT License | 5 votes |
@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); }
Example #9
Source File: ControllerInputIntegrationTests.java From spring-analysis-note with MIT License | 5 votes |
@GetMapping("/{one}/{two}/{three}-{four}") public String matrixVar( @MatrixVariable int p, @MatrixVariable(name = "q", pathVar = "two") int q2, @MatrixVariable(name = "q", pathVar = "four") int q4) { return "p=" + p + ", q2=" + q2 + ", q4=" + q4; }
Example #10
Source File: MatrixVariableMapMethodArgumentResolver.java From java-technology-stack with MIT License | 5 votes |
@Nullable @Override public Object resolveArgumentValue(MethodParameter parameter, BindingContext bindingContext, ServerWebExchange exchange) { Map<String, MultiValueMap<String, String>> matrixVariables = exchange.getAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE); if (CollectionUtils.isEmpty(matrixVariables)) { return Collections.emptyMap(); } MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); MatrixVariable annotation = parameter.getParameterAnnotation(MatrixVariable.class); Assert.state(annotation != null, "No MatrixVariable annotation"); String pathVariable = annotation.pathVar(); if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) { MultiValueMap<String, String> mapForPathVariable = matrixVariables.get(pathVariable); if (mapForPathVariable == null) { return Collections.emptyMap(); } map.putAll(mapForPathVariable); } else { for (MultiValueMap<String, String> vars : matrixVariables.values()) { vars.forEach((name, values) -> { for (String value : values) { map.add(name, value); } }); } } return (isSingleValueMap(parameter) ? map.toSingleValueMap() : map); }
Example #11
Source File: ControllerInputIntegrationTests.java From java-technology-stack with MIT License | 5 votes |
@GetMapping("/{one}/{two}/{three}-{four}") public String matrixVar( @MatrixVariable int p, @MatrixVariable(name = "q", pathVar = "two") int q2, @MatrixVariable(name = "q", pathVar = "four") int q4) { return "p=" + p + ", q2=" + q2 + ", q4=" + q4; }
Example #12
Source File: MatrixVariablesMapMethodArgumentResolverTests.java From java-technology-stack with MIT License | 5 votes |
@SuppressWarnings("unused") 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) { }
Example #13
Source File: MatrixVariableMapMethodArgumentResolver.java From java-technology-stack with MIT License | 5 votes |
@Override @Nullable public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest request, @Nullable WebDataBinderFactory binderFactory) throws Exception { @SuppressWarnings("unchecked") Map<String, MultiValueMap<String, String>> matrixVariables = (Map<String, MultiValueMap<String, String>>) request.getAttribute( HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST); if (CollectionUtils.isEmpty(matrixVariables)) { return Collections.emptyMap(); } MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); MatrixVariable ann = parameter.getParameterAnnotation(MatrixVariable.class); Assert.state(ann != null, "No MatrixVariable annotation"); String pathVariable = ann.pathVar(); if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) { MultiValueMap<String, String> mapForPathVariable = matrixVariables.get(pathVariable); if (mapForPathVariable == null) { return Collections.emptyMap(); } map.putAll(mapForPathVariable); } else { for (MultiValueMap<String, String> vars : matrixVariables.values()) { vars.forEach((name, values) -> { for (String value : values) { map.add(name, value); } }); } } return (isSingleValueMap(parameter) ? map.toSingleValueMap() : map); }
Example #14
Source File: MatrixVariableMethodArgumentResolver.java From java-technology-stack with MIT License | 5 votes |
@Override public boolean supportsParameter(MethodParameter parameter) { if (!parameter.hasParameterAnnotation(MatrixVariable.class)) { return false; } if (Map.class.isAssignableFrom(parameter.nestedIfOptional().getNestedParameterType())) { MatrixVariable matrixVariable = parameter.getParameterAnnotation(MatrixVariable.class); return (matrixVariable != null && StringUtils.hasText(matrixVariable.name())); } return true; }
Example #15
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From java-technology-stack with MIT License | 5 votes |
@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); }
Example #16
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From java-technology-stack with MIT License | 5 votes |
@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); }
Example #17
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From java-technology-stack with MIT License | 5 votes |
@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")); }
Example #18
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From java-technology-stack with MIT License | 5 votes |
@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); }
Example #19
Source File: MatrixVariablesMapMethodArgumentResolverTests.java From java-technology-stack with MIT License | 5 votes |
@SuppressWarnings("unused") 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) { }
Example #20
Source File: MvcAnnotationPredicates.java From java-technology-stack with MIT License | 5 votes |
@Override public boolean test(MethodParameter parameter) { MatrixVariable annotation = parameter.getParameterAnnotation(MatrixVariable.class); return annotation != null && (this.name == null || this.name.equalsIgnoreCase(annotation.name())) && (this.pathVar == null || this.pathVar.equalsIgnoreCase(annotation.pathVar())); }
Example #21
Source File: MatrixVariableMapMethodArgumentResolver.java From lams with GNU General Public License v2.0 | 5 votes |
@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; }
Example #22
Source File: MatrixVariableMapMethodArgumentResolver.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest request, WebDataBinderFactory binderFactory) throws Exception { @SuppressWarnings("unchecked") Map<String, MultiValueMap<String, String>> matrixVariables = (Map<String, MultiValueMap<String, String>>) request.getAttribute( HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST); if (CollectionUtils.isEmpty(matrixVariables)) { return Collections.emptyMap(); } MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); String pathVariable = parameter.getParameterAnnotation(MatrixVariable.class).pathVar(); if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) { MultiValueMap<String, String> mapForPathVariable = matrixVariables.get(pathVariable); if (mapForPathVariable == null) { return Collections.emptyMap(); } map.putAll(mapForPathVariable); } else { for (MultiValueMap<String, String> vars : matrixVariables.values()) { for (String name : vars.keySet()) { for (String value : vars.get(name)) { map.add(name, value); } } } } return (isSingleValueMap(parameter) ? map.toSingleValueMap() : map); }
Example #23
Source File: MatrixVariableMethodArgumentResolver.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public boolean supportsParameter(MethodParameter parameter) { if (!parameter.hasParameterAnnotation(MatrixVariable.class)) { return false; } if (Map.class.isAssignableFrom(parameter.nestedIfOptional().getNestedParameterType())) { String variableName = parameter.getParameterAnnotation(MatrixVariable.class).name(); return StringUtils.hasText(variableName); } return true; }
Example #24
Source File: MatrixVariableMapMethodArgumentResolver.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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; }
Example #25
Source File: MatrixVariableMethodArgumentResolver.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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; }
Example #26
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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); }
Example #27
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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); }
Example #28
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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")); }
Example #29
Source File: UriTemplateServletAnnotationControllerHandlerMethodTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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); }
Example #30
Source File: MatrixVariablesMapMethodArgumentResolverTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
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) { }