java - Spring model attribute gets null within the request -


i have page pagination links @ top. when click pages takes me record 1-50, 51-100 , on. having issue when click second action when click page # 2 @modelattribute values gets null.

this tha page url: http://localhost:8080/tax/taxedyear.html?p=2

it takes me spring controller class /taxedyear.html , method below:

@requestmapping(value = "/taxedyear.html", method = requestmethod.get)     public modelandview showtaxresults(@modelattribute("criteria")     criteria criteria, model model, httpsession session, httpservletrequest request) {       string src = criteria.getsource();     system.out.println("src === "+src);     //....     //     } 

when called criteria null. same method called previou page , works fine. happens when click page urls calls same method in controller , sends page # in addition.

from spring reference:

an @modelattribute on method argument indicates argument should retrieved model. if not present in model, argument should instantiated first , added model.

model populated controller. assume model remains same when second call made, apparently assumption wrong. because spring initializes model, believe thought it's persistent. , reasonable way, model shouldn't persistent among http calls.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -