Spring mvc. case insensitive get parameters mapping

后端 未结 3 635
温柔的废话
温柔的废话 2021-01-11 15:52

according this answer I try to write my code:

pojo:

class MyBean{

    public String getValueName() {
        return valueName;
    }

    public void          


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-11 16:01

    Your problem, I believe, is @ModelAttribute. You're asking Spring to map the parameters to MyBean object, and the property inside this object is valueName.

    In order Spring to reflect the params to the object, it needs to be in the correct case.

    You have 2 options:

    • change the property name to valuename in your MyBean object, and all property names to lowercase, it should work with help of your solution.
    • remove @ModelAttribute and put @RequestParam for each property. If you have many props, this could be painful.

提交回复
热议问题