在jsp:param中传递Java变量 [英] pass java variable in jsp:param

查看:339
本文介绍了在jsp:param中传递Java变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <%!  
    String str = "prerna";  
  %>  

 <jsp:include page="index.html">
      <jsp:param name="type1" value=<%=str%> >
      </jsp:param>  
 </jsp:include>

我想在param标签中传递一个Java变量,但是我不确定该怎么做.

I want to pass a java variable in the param tag,but i am not sure how to do it.

我也想在index.html中访问它.
谁能建议我这样做的方法?

I also want to access it in index.html.
Can anyone suggest me the way to do it ?

推荐答案

只需将其直接放在value中.

<jsp:include page="index.html">
    <jsp:param name="type1" value="prerna" />
</jsp:include>

或使用JSTL <c:set>进行设置,并使用EL ${}进行获取.

Or use JSTL <c:set> to set it and EL ${} to get it.

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
...
<c:set var="type1" value="prerna" />
...
<jsp:include page="index.html">
    <jsp:param name="type1" value="${type1}" />
</jsp:include>

如果包含的页面是一个jsp,则可以将其用作${param.type1}

And if your included page is a jsp, then you can use it as ${param.type1}

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

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