0

I have a spring boot code like following which handles a particular mapping like following -

@RestController
@ResponseBody
public class SomeAPIController {

    @RequestMapping(
            value = "/some-api",
            method = RequestMethod.GET,
            produces = {"application/json", "application/xml"}
    )

    @ResponseStatus(HttpStatus.OK)
    @ResponseBody
    public SomeAPIPayload validateAPIUpdate(
            @Valid @RequestParam(value = "query", defaultValue="") String queryString

    )

But in above code if I pass query as "something" it works fine but if I pass say, "#something" it fails to query(I verified it by printing queryString value, and it comes out to be empty) so, as far my understanding @Valid(which is imported from javax.validation) is doing some validation and doesn't let "#something" pass. I want to know how to track down the validation file or if something other is wrong how to locate it ? Any pointers in direction will be extremely helpful.

Thanks.

Polish
  • 554
  • 1
  • 4
  • 18

2 Answers2

1

Everything following a hash (#) is interpreted as anchor/fragment and will not be sent to the server as stated in RFC 1738. To send a hash symbol, you need to encode it as %23.

Hannes
  • 2,018
  • 25
  • 32
1

# in URL stands for a fragment identifier. So if your query is http://example.com?query=#something then the #something part is considered a fragment identifier and the query parameter is empty.

Kirill Simonov
  • 8,257
  • 3
  • 18
  • 42