Unwanted comma-splitting when binding string (from inputText) to List in Spring -


I am working with the Spring Web, my JSP is an input text that I am typing in because I I can set input text. The problem is that if I have any input text like "yyyyMMdd hh: mm: ss, SSS", I found a list with two elements: "yyyyMMdd hh: mm: ss" and "sss", when I with all the text Just want to get one. Why?

This is the default behavior of how binding works in the spring if you have only one input, and If there is a comma with value for that input, then the spring will change it into the list of values ​​for that attribute.

Assume that you have:

  & lt; Input type = "hidden" name = "field" value = "hi, SO" & gt;   

Mapping list in the DTO for feature & lt; String & gt; The field will be set to ["Hi", "SO"].

To overcome this, you may get an extra free input just before those people with the actual value of that field. / p>

  & lt; Input type = "hidden" name = "field" value = "" & gt;   

In this fields will set the value in ["", "hi, SO"] and you can handle empty string accordingly in your logic.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -