java - Spring request parameters saved by binder -
i think may have discovered critical bug springs web binder, or more likely, doing horribly wrong. basically, data 1 servlet request somehow copied request.
spring version 4.1.5
i have simple model object 1 parameter.
public class mymodelattribute { private string mymodelparameter; public string getmodelparameter() { return mymodelparameter; } public void setmodelparameter(string mymodelparameter) { this.mymodelparameter = mymodelparameter; } }
i intialize binder object in controller
@initbinder("mymodelattribute") protected void initmymodelbinder(webdatabinder binder) { binder.setvalidator(myvalidator); binder.registercustomeditor(string.class, new stringtrimmereditor(false)); }
then there controller method this
public modelandview somerequestmapping(@valid @modelattribute("mymodelattribute") mymodelattribute mymodelattribute, bindingresult bindingresult) { ... }
i created test spams controller requests , see horrifying. parameter on model not submitted, rather, different value submitted in earlier request. make 1 user user's data. basically, seems target object on data binder saved earlier. if parameter directly request expected parameter.
the issue stringtrimmer editor... wasnt set posted in code. binder intialization this. , turns out stringtrimmereditor not stateless. answer initialize binder in question. not how below.
@initbinder("mymodelattribute") protected void initmymodelbinder(webdatabinder binder) { binder.setvalidator(myvalidator); binder.registercustomeditor(string.class, string_trimmer); }
the issue better described here https://jira.spring.io/browse/spr-12547
Comments
Post a Comment