0

我有以下代码:

宝约:

class MyBean{

    public String getValueName() {
        return valueName;
    }

    public void setValueName(String valueName) {
        this.valueName = valueName;
    }

    String valueName;
}

内部控制器:

@ModelAttribute
    public MyBean createMyBean() {
        return new MyBean();
    }
    @RequestMapping(value = "/getMyBean", method = RequestMethod.GET)
    public String getMyBean(@ModelAttribute MyBean myBean) {
        System.out.println(myBean.getValueName());
        return "pathToJsp";
    }

配置:

@Configuration
@EnableWebMvc
public class Configiuration extends WebMvcConfigurerAdapter {


    ...

    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        AntPathMatcher matcher = new AntPathMatcher();
        matcher.setCaseSensitive(false);
        configurer.setPathMatcher(matcher);
    }
}

当我转到网址时

localhost:8081/getMyBean?valueName=trololo

trololo在控制台中看到

当我转到网址时

localhost:8081/getMyBean?valuename=trololo

我在控制台中看到 null 。

如何解决我的问题?

4

0 回答 0