[当我将SubmitState
设置为ModelAndView
的属性时,我遇到以下异常:
java.lang.IllegalStateException: Cannot convert value of type 'example.package.SubmitState' to required type 'java.lang.String': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:262)
at org.springframework.beans.TypeConverterSupport.convertIfNecessary(TypeConverterSupport.java:73)
设置方法:model.addAttribute(someField, submitState);
设置完成后,我尝试重定向到页面,但出现异常。
SubmitState:
public class SubmitState implements Serializable {
private String msgClass;
private String msgKey;
public void setMsgClass(String msgClass) {
this.msgClass = msgClass;
}
public String getMsgClass() {
return msgClass;
}
public void setMsgKey(String msgKey) {
this.msgKey = msgKey;
}
public String getMsgKey() {
return msgKey;
}
}
model.addAttribute("some-key", submitState);