Questions tagged [request-mapping]

Issues regarding usage of Spring MVC @RequestMapping methods

348 questions
2
votes
1 answer

Can Spring MVC strictly map query strings to request parameters?

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…
David J
  • 21
  • 3
2
votes
1 answer

Spring RequestBody Mapping maps all attributes to null values

i have the following RESTfull method : @RequestMapping(value = "/budgetLines", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public void create(@RequestBody BudgetLine budgetLine) { …
Morty
  • 3,463
  • 4
  • 17
  • 21
2
votes
1 answer

How to map Spring Interceptor

I'm trying to map a Spring Interceptor so it catches every '*.do' request, but I can only make it work in a 'single level'. My Interceptor mapping path is "/*.do", and I can only intercept URIs like /app/action.do If I request…
2
votes
1 answer

Spring controller request mapping issue for dot in resource

I am using spring 3.2.2 jars and have a controller with mapping "/validate". If i invoke "/validate.123" in browser url, this mapping method get executed which shouldn't be. Is't a problem in my code or spring…
skumar
  • 985
  • 4
  • 14
  • 37
2
votes
1 answer

Spring @RequestMapping Controller Forwarding

@RequestMapping({"/someurl"}) public String execute(Model model) { if (someCondition) { return "forward:/someUrlA"; } else { return "forward:/someUrlB"; } } Im trying to forward request from a controller to another…
user1955934
  • 3,185
  • 5
  • 42
  • 68
1
vote
0 answers

Spring adds request mappings for beans that aren't annotated with @Controller

I have a library that contains the DTO and service interface. @RequestMappping("/api/foo") public interface FooApi { @GetMapping("/{id}") Foo getFooById(@pathVariable long id); } The server implements that interface: @RestController public…
ST-DDT
  • 2,615
  • 3
  • 30
  • 51
1
vote
0 answers

linkTo(): Not enough variable values to expand when @RequestMapping("${app-controller.path}") comes from properties

we have a working asynchronous REST API with Spring Boot and Hateoas: @RestController @EnableAutoConfiguration @RequestMapping("/metfrag/api/v1") /** @RequestMapping("${metfragrest-controller.path}") Fail in linkTo() **/ public class…
1
vote
1 answer

Spring RequestMapping with a regular expression for all levels

Let's say I need to map requests which don't have . to add a suffix for them, for example: /a /a/b /a/b/c but not /a.html /a/b.html /a/b/c.html I am able to map it with a a particular level, with something like the below, but that means a new…
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
1
vote
2 answers

Spring RequestMapping doesn't split RequestParam and RequestBody

I want to implement a POST endpoint where it is possible to accept or refuse programmatically the data sent, depending if it comes from querystring or from x-www-form-urlencoded data. I…
Sampisa
  • 1,487
  • 2
  • 20
  • 28
1
vote
1 answer

RequestMapping not working in Spring with Docker

I'm trying to make a simple CRUD of Students using Spring Boot. I am storing data in a class inside Spring, and not in files or a DB. So my changes are lost everytime I run it again. I'm planning to use MongoDB, but now I'm just trying this simple…
1
vote
1 answer

spring boot mapping without slash

I'm having a controller mapping as shown below @RestController @RequestMapping("/v1/connector") public class Controller and the API mapping as below @GetMapping("2/auth") when I hit the URL it's giving me the response as request URL not found. Can…
1
vote
1 answer

SpringBoot 2.6.2 and form data

I am experimenting with a controller endpoint that looks like this: @PostMapping("login") fun login( @RequestParam username: String, @RequestParam password: String): ResponseEntity { // ... } The request is send from a…
Sjoerd222888
  • 3,228
  • 3
  • 31
  • 64
1
vote
1 answer

Access @PathVariables from parent's @RequestMapping

I'm trying to access the @PathVariables defined in "MyClass"'s @RequestMapping parent. Simplified screnario: @RestController @RequestMapping(value = "some/path/{with}/{multiple}/{variables}") public class ParentClass {...} This class is sort of a…
1
vote
1 answer

Error Http Post - Spring - @RequestMapping - @Controller

I´ve read a lot but I did not find any good answers regarding to my problem. Indeed, this my class : @Controller public class ServletController { @RequestMapping(value = {"", "/testControlP"}, method = RequestMethod.POST) @ResponseBody …
RaphaelB
  • 21
  • 1
1
vote
2 answers

Thymleaf how to take an input and then redirect to another page

I'm learning Spring boot. I have a list of products with unique ids, and I want to implement a "lookup by id" functionality, but I don't know how to do it, I searched but got totally different stuff. I already have a @Getmapping method like…
Veritas1832
  • 67
  • 3
  • 14