将变量传递给jsp
问题描述:
我有一个Java类
public void doView(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException {
//I need to pass the string variable over to my jsp
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
String sLang_Id = themeDisplay.getLanguageId();
include("/html/mypackage/view.jsp", renderRequest, renderResponse);
}
我如何在我的jsp中阅读sLang_Id
How would I read sLang_Id
in my jsp
<c:out value="${sLang_Id}" /> ???
答
在调用include
方法之前添加以下内容:
Add the following before your call to the include
method:
renderRequest.setAttribute("sLang_Id", sLang_Id);