将变量传递给jsp

时间:2011-12-07 04:09:02

标签: java jsp liferay portlet cout

我有一个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

 <c:out value="${sLang_Id}" /> ???

1 个答案:

答案 0 :(得分:5)

在致电include方法之前添加以下内容:

renderRequest.setAttribute("sLang_Id", sLang_Id);

API可供http://portals.apache.org/pluto/portlet-2.0-apidocs/index.html?javax/portlet/RenderRequest.html参考。