如何为JSTL变量分配隐藏值? [英] How do I assign hidden value to JSTL variable?
问题描述
如何为JSTL变量分配隐藏值?
How do I assign hidden value to JSTL variable?
示例:
<input type="hidden" name="userName" value="Administrator" />
<c:set var="user" value="" /> // How do I set hidden variable value (Administrator) here?
推荐答案
我假设您实际上的意思是:如何将已提交的隐藏输入值分配给JSTL变量?",因为您当前提出的问题没有任何意义.您可以只复制标签中的值.
I assume that you actually mean: "How do I assign submitted hidden input value to a JSTL variable?", because the question as you currently state makes no sense. You could just copy the value in the tag.
您可以通过隐式EL对象${param}
访问请求参数,该对象可以像Map
一样进行访问.
You can access request parameters by the implicit EL object ${param}
which can be accessed like a Map
.
<c:set var="user" value="${param.userName}" />
在后台,这会将request.getParameter("userName")
的结果分配给页面范围中的变量名称user
.
Behind the scenes, this assigns the result of request.getParameter("userName")
to a variable name user
in the page scope.
也就是说,我质疑这种需求的价值.也许是时候了解更多有关作为页面控制器的servlet和作为模型对象的Javabean的知识了吗?
That said, I question the value of this need. Maybe it's time to learn a bit more about servlets as page controllers and Javabeans as model objects?
- Basic/intermediate JSP/Servlet tutorials
- Implicit Objects in Expression Language
- Hidden features of JSP/Servlet
这篇关于如何为JSTL变量分配隐藏值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!