request-mapping

Forward JSON POST request from one REST API to another

房东的猫 提交于 2020-01-23 08:24:07
问题 I have the following situation: My REST API one: @RestController @RequestMapping("/controller1") Public Class Controller1{ @RequestMapping(method = RequestMethod.POST) public void process(@RequestBody String jsonString) throws InterruptedException, ExecutionException { ............ } } JSON POST request, request1, for the REST API(Controller1): { "key1":"value1", "key2":"value2" } My REST API two: @RestController @RequestMapping("/controller2") Public Class Controller2{ @RequestMapping(method

Forward JSON POST request from one REST API to another

冷暖自知 提交于 2020-01-23 08:23:46
问题 I have the following situation: My REST API one: @RestController @RequestMapping("/controller1") Public Class Controller1{ @RequestMapping(method = RequestMethod.POST) public void process(@RequestBody String jsonString) throws InterruptedException, ExecutionException { ............ } } JSON POST request, request1, for the REST API(Controller1): { "key1":"value1", "key2":"value2" } My REST API two: @RestController @RequestMapping("/controller2") Public Class Controller2{ @RequestMapping(method

Can Spring MVC strictly map query strings to request parameters?

别说谁变了你拦得住时间么 提交于 2020-01-04 21:35:46
问题 Is there any way to configure Spring-MVC to strictly accept a known list of query strings? I'm looking to validate submitted query strings -- if a request has additional query string parameters, I'd like to know about it and return a 404. My motivations are as follows: Clarity: I don't want clients to fat-finger a request parameter, and still get results back (as if no request parameter was supplied) HTTP caching: I'd like to limit the number of valid HTTP routes for my service so that HTTP

Can Spring MVC strictly map query strings to request parameters?

我的未来我决定 提交于 2020-01-04 21:34:07
问题 Is there any way to configure Spring-MVC to strictly accept a known list of query strings? I'm looking to validate submitted query strings -- if a request has additional query string parameters, I'd like to know about it and return a 404. My motivations are as follows: Clarity: I don't want clients to fat-finger a request parameter, and still get results back (as if no request parameter was supplied) HTTP caching: I'd like to limit the number of valid HTTP routes for my service so that HTTP

Is produces of @RequestMapping sensitive to order of values?

我是研究僧i 提交于 2020-01-03 02:04:45
问题 This question is based on this question. With provided comments, i had written three different tests to validate properly set content-types. @Test public void testGetImageJpg_ShouldSucceed() throws Exception { File testImage = new File(TestConstants.TEST_IMAGE_JPG); byte[] expectedBytes = IOUtils.toByteArray(new FileInputStream(testImage)); when(service.getImage(anyString(), anyString())).thenReturn(testImage); mockMvc.perform(get("/getImage/id/bla.jpg").sessionAttrs(session)) .andExpect

Spring @RequestMapping header with equals

这一生的挚爱 提交于 2019-12-24 14:06:30
问题 I want to use Springs @RequestMapping with the header attribute to detect an Accept header with the value application/json;version=1.* . The plan is to have another method mapped similarly for version 2 which will have the value application/json;version=2.* . Spring seems to be ignoring the version value. I'm guessing it's treating the equals sign as another header attribute. Is there a way around this? Side notes: I can't update the Spring version to support the consumes attribute I can't

GET/POST Requst to REST API using Spring Boot

ⅰ亾dé卋堺 提交于 2019-12-24 00:37:01
问题 I have a REST Service an external server like https://api.myrestservice.com and I have a Spring Boot Application running locally on http://localhost:8080 . Now I want to make GET or POST request to the REST API address i.e https://api.myrestservice.com/users to get all users, using my locally running Spring Boot App i.e through http://localhost:8080/users . I am not getting how to redirect local app request to external server request. 回答1: I hope I got your question right. You are trying get

Spring @RequestMapping “Not Contains” Regex

我的梦境 提交于 2019-12-20 04:58:11
问题 I have this RequestMapping: @RequestMapping(value = "/route/to-{destination}-from-{departure}.html", method = {RequestMethod.GET, RequestMethod.HEAD}) And I would like to add that RequestMapping: @RequestMapping(value = "/route/to-{destination}.html", method = {RequestMethod.GET, RequestMethod.HEAD}) So it can serve all the "without departure" routes. That, however, creates a conflict as a "/route/to-destination-from-departure" url actually match this second RequestMapping as well... Fair

how to apply user defined properties value to @RequestMapping

时间秒杀一切 提交于 2019-12-20 03:15:20
问题 I have several @RequestMapping which value will subject to change from "/XXX" to "/V100" on someday. So I need to define it in properties. I've googled and there's way using application.properties but I have to keep "/XXX" value in a user defined properties like a "local.properties". Is it possible to define @RequestMapping value on a user defined properties? @Controller @RequestMapping("/XXX") public class MyController { ... } ** UPDATE : tried several hours and get it to work. my.properties

Spring 3 MVC accessing HttpRequest from controller

拜拜、爱过 提交于 2019-12-17 02:34:44
问题 I would like to handle request and session attributes myself rather then leave it to spring @SessionAttributes , for login of cookies handling for example. I just cant figure out how could I access the HttpRequest from within a controller, I need a way to go a layer above the @RequestAttribute and access the HttpRequest itself. With Stripes in used to do this by implementing an ApplicationContext and calling getAttribute() . Also, passing the HttpServletRequest as parameter seems not to be