0
我正在實現Spring MVC。不同的字符串值顯示在jsp頁面上。字符串ArrayList <String>
幫助我將這些字符串值移動到ArrayList以減少龐大的代碼。
@Controller("Control")
Public Class Controller{
...
@RequestMapping()
public String init(RenderRequest request, RenderResponse response,
Model model) {
try {
String auth = request.getAuthType(); //All these Strings to be moved to 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 could also be 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;
}
還幫我換了JSP也使用
<%My JSP%>
<tr>
<td>Pcontexts------${Pcontext}</td>
</tr>
<tr>
<td>auths------${auth}</td>
</tr>
...
//To be changed to something using <c:ForEach or some Loop>
更新:
當我加入這個控制器,並做如Bozho顯示,在JSP,它仍然沒有不工作:
model.addAttribute("paramsMap", request.getParameterMap());
你能提供一些控制器的代碼片段嗎? – 2011-02-09 13:14:53