将变量传递给jsp [英] Passing variable to jsp

查看:76
本文介绍了将变量传递给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);

可以在 http上参考的

API. ://portals.apache.org/pluto/portlet-2.0-apidocs/index.html?javax/portlet/RenderRequest.html .

这篇关于将变量传递给jsp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆