jjzjj

pathVariable

全部标签

java - 将数组或列表传递给@Pathvariable - Spring/Java

我在JBoss/Spring中做一个简单的“获取”。我希望客户端在url中向我传递一个整数数组。我如何在服务器上设置它?并显示客户端应该发送消息吗?这就是我现在所拥有的。@RequestMapping(value="/test/{firstNameIds}",method=RequestMethod.GET)@ResponseBodypublicStringtest(@PathVariableListfirstNameIds){//WhatdoIdo??return"Dummy";}在客户端我想传递类似的东西http://localhost:8080/public/test/[1,3,

spring - Spring 4 中的@PathVariable 验证

如何在Spring验证我的路径变量。我想验证id字段,因为它唯一的单个字段我不想移动到Pojo@RestControllerpublicclassMyController{@RequestMapping(value="/{id}",method=RequestMethod.PUT)publicResponseEntitymethod_name(@PathVariableStringid){///Somecode}}我尝试向路径变量添加验证,但仍然无法正常工作@RestController@ValidatedpublicclassMyController{@RequestMapping(

spring - Spring 4 中的@PathVariable 验证

如何在Spring验证我的路径变量。我想验证id字段,因为它唯一的单个字段我不想移动到Pojo@RestControllerpublicclassMyController{@RequestMapping(value="/{id}",method=RequestMethod.PUT)publicResponseEntitymethod_name(@PathVariableStringid){///Somecode}}我尝试向路径变量添加验证,但仍然无法正常工作@RestController@ValidatedpublicclassMyController{@RequestMapping(

java - ZonedDateTime 作为 Spring REST RequestMapping 中的 PathVariable

我的Spring应用程序中有一个REST端点,看起来像这样@RequestMapping(value="/customer/device/startDate/{startDate}/endDate/{endDate}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)publicPagegetDeviceListForCustomerBetweenDates(@PathVariableZonedDateTimestartDate,@PathVariableZonedDateTimeendDate,Pa

java - ZonedDateTime 作为 Spring REST RequestMapping 中的 PathVariable

我的Spring应用程序中有一个REST端点,看起来像这样@RequestMapping(value="/customer/device/startDate/{startDate}/endDate/{endDate}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)publicPagegetDeviceListForCustomerBetweenDates(@PathVariableZonedDateTimestartDate,@PathVariableZonedDateTimeendDate,Pa

java - 用于 Spring MVC 4 Controller 的 Junit 测试用例检查 @RequestMapping 中的 @PathVariable 参数

我有以下Controller代码,我必须为其编写JUnit测试用例。publicclassEquipmentController{privateMapequiList=newHashMap();@RequestMapping("/rest/equipment/{Number}")publicEquipmentgetEquipment(@PathVariableStringNumber){if(!equiList.containsKey(Number)){lNumber=DEFAULT;}returnequiList.get(Number);}}我正在编写与以下相同的JUnit测试用例:

java - 用于 Spring MVC 4 Controller 的 Junit 测试用例检查 @RequestMapping 中的 @PathVariable 参数

我有以下Controller代码,我必须为其编写JUnit测试用例。publicclassEquipmentController{privateMapequiList=newHashMap();@RequestMapping("/rest/equipment/{Number}")publicEquipmentgetEquipment(@PathVariableStringNumber){if(!equiList.containsKey(Number)){lNumber=DEFAULT;}returnequiList.get(Number);}}我正在编写与以下相同的JUnit测试用例:

java - 如何匹配具有包含 "/"的 @pathVariable 的 Spring @RequestMapping?

我正在执行来自客户端的以下请求:/search/hello%2Fthere/搜索词“hello/there”已被URL编码。在服务器上,我尝试使用以下请求映射匹配此URL:@RequestMapping("/search/{searchTerm}/")publicMapsearchWithSearchTerm(@PathVariableStringsearchTerm){//morecodehere}但是我在服务器上收到错误404,因为我没有任何匹配的URL。我注意到URL在Spring获取之前已被解码。因此正在尝试匹配没有任何匹配项的/search/hello/there。我在这里找

java - 如何匹配具有包含 "/"的 @pathVariable 的 Spring @RequestMapping?

我正在执行来自客户端的以下请求:/search/hello%2Fthere/搜索词“hello/there”已被URL编码。在服务器上,我尝试使用以下请求映射匹配此URL:@RequestMapping("/search/{searchTerm}/")publicMapsearchWithSearchTerm(@PathVariableStringsearchTerm){//morecodehere}但是我在服务器上收到错误404,因为我没有任何匹配的URL。我注意到URL在Spring获取之前已被解码。因此正在尝试匹配没有任何匹配项的/search/hello/there。我在这里找

java - Spring MVC中的多个@PathVariable

很遗憾无法找到答案,希望有人能提供帮助。在SpringMVC3.1.0中,这是我的方法:@RequestMapping(value="/{app}/conf/{fnm}",method=RequestMethod.GET)publicResponseEntitygetConf(@PathVariableStringapp,@PathVariableStringfnm){log.debug("AppName:"+app);log.debug("fName:"+fnm);...return...}我在网上看过一些例子,理论上有多个@PathVariables似乎没有问题。但是当我这样做时,