简体   繁体   English

将变量传递给jsp

[英]Passing variable to jsp

I have a java class 我有一个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);

}

How would I read sLang_Id in my jsp 我怎样才能在jsp中读取sLang_Id

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

Add the following before your call to the include method: 在调用include方法之前添加以下内容:

renderRequest.setAttribute("sLang_Id", sLang_Id);

API available for reference at http://portals.apache.org/pluto/portlet-2.0-apidocs/index.html?javax/portlet/RenderRequest.html . API可在http://portals.apache.org/pluto/portlet-2.0-apidocs/index.html?javax/portlet/RenderRequest.html上参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM