java - String to ArrayList<String> -
i implementing spring mvc. different string values displayed on jsp page.
help me move string values arraylist reduce bulky code.
@controller("control") public class controller{ ... @requestmapping() public string init(renderrequest request, renderresponse response, model model) { try { string auth = request.getauthtype(); //all these strings moved arraylist<string> string context = request.getcontextpath(); string etags = request.getetag(); string remoteuser = request.getremoteuser(); string sessionid = request.getrequestedsessionid(); string rescontent = request.getresponsecontenttype(); string scheme = request.getscheme(); string getservername = request.getservername(); string getwindowid = request.getwindowid(); portletmode getportletmode = request.getportletmode(); //if these different types moved <?> portalcontext pcontext = request.getportalcontext(); model.addattribute("name", "sallu"); model.addattribute("auth",auth); model.addattribute("context", context); model.addattribute("etags",etags); model.addattribute("remoteuser", remoteuser); model.addattribute("sessionid",sessionid); model.addattribute("rescontent",rescontent); model.addattribute("scheme", scheme); model.addattribute("getservername",getservername); model.addattribute("getwindowid", getwindowid); model.addattribute("getportletmode",getportletmode); model.addattribute("pcontext",pcontext); } catch (exception ex) { log.error(errorutil.convertstacktracetostring(ex)); } return jsp_page; }
also me change jsp using
<%my jsp%> <tr> <td>pcontexts------${pcontext}</td> </tr> <tr> <td>auths------${auth}</td> </tr> ... //to changed using <c:foreach or loop>
update:
when add controller, , bozho showed in jsp, still not work:
model.addattribute("paramsmap", request.getparametermap());
you can use request.getparametermap()
- give map
can iterate in jsp:.
<c:foreach items="${paramvalues}" var="mapentry"> <td>${mapentry.key}</td> <td>${mapentry.value}</td> </c:foreach>
paramvalues
above implicit variable contains map.
when using forward, need nothing else in controller. can use: model.addattribute("paramsmap", request.getparametermap())
, should not necessary.
Comments
Post a Comment