0

I have a code in Spring 2.5, which is working fine. I am trying to migrate to Spring5. As part of that, few requests failing with response code 400.

Reason is - null value in one of the Params in query string.

Spring 2.5 was allowing that.

Example:

request.do?param1=value&param2=null

I don't want to refactor the existing code.

Is there any configuration in spring 5 to allow this? Or what is the minimal or easiest way to fix this?

Shanu Gupta
  • 3,699
  • 2
  • 19
  • 29
  • this link might help - https://stackoverflow.com/questions/43780226/spring-data-ignore-parameter-if-it-has-a-null-value – JavaLearner1 Jul 03 '18 at 05:19
  • Actually mine is Spring MVC application. I am getting values from JSP- (all query string and post data) in controller as @ModelAttribute. So, if any one of the Params in querystring is null, binding is failing and getting 400 response. Is there anyway to tell spring to allow null as part of binding or some thing like custom binders? – Sankaranarayana Kishakkamadam Jul 03 '18 at 05:24
  • looks like param2 is a primitive type(may be int or long), so it is not allowing the null value. If it is a objet/string then as a requestParam it should allow. Please verify and change it to wrapper class if that's the case. – Sunil Gollapinni Jul 03 '18 at 06:40

0 Answers0