我有以下代码:
POJO:
supportedInterfaceOrientations
控制器内部:
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
我在控制台中看到null。
如何解决我的问题?