java - HttpServletRequest stored in model gets replaced -
i'm working on legacy code (spring 2.5.x, java 1.5), controller passes http servlet request view this:
public modelandview handlerequest(httpservletrequest request, httpservletresponse response) throws exception { map attributes = new hashmap(); attributes.put("httprequest", request); return new modelandview("/path/to/page.jsp", attributes); }
however happens httprequest attribute indeed exist in jsp page context, contains current request (jsp page) , not original (controller). passed request being used extract information url. appears can around problem using bunch of "javax.servlet.forward.*" attributes. puzzles me pretty simple thing , i'd happy work anyways or @ least know why doesn't work now. has ideas?
to begin with, bad idea store request attribute of request. if need specific data current request, can retrieve directly using ${requestcontext}
, if need access url, use ${requestcontext.requesturl}
. if need access parts of url display in client side, better parse url in server side (controller) first obtaining using stringbuffer url = request.getrequesturl();
, setting required data attributes.
Comments
Post a Comment