java - 将变量传递给jsp

标签 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}" /> ???

最佳答案

在调用 include 方法之前添加以下内容:

renderRequest.setAttribute("sLang_Id", sLang_Id);

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

关于java - 将变量传递给jsp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8410283/

相关文章:

java - Tomcat:如何将 http:\\localhost\myFolder 链接到 C:\testFolder

java - 使用 Spring 和 Rest Web 服务将文件从服务器发送到客户端 java

java - 实例化: <jsp:useBean> vs.新关键字

javascript - Liferay 门户组件 : redirect to an other jsp page from javascript

liferay - PortletURLListener 是做什么用的?我可以在钩子(Hook)中使用它吗?

java - Liferay 的 Axis 日志错误

java - 从另一个字符串数组中过滤字符串数组

java - 允许用户在 Java 运行时重新定义 Swing 的热键

java - 查找阴影对象

java - 异常后显示来自 liferay Hook 服务的自定义错误消息