开发者

How do I assign hidden value to JSTL variable?

开发者 https://www.devze.com 2023-01-07 20:24 出处:网络
How do I assign hidden value to JSTL variable? Example: <inpu开发者_如何学编程t type=\"hidden\" name=\"userName\" value=\"Administrator\" />

How do I assign hidden value to JSTL variable?

Example:

<inpu开发者_如何学编程t type="hidden" name="userName" value="Administrator" />
<c:set var="user" value="" />  // How do I set hidden variable value (Administrator) here?


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.

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}" />

Behind the scenes, this assigns the result of request.getParameter("userName") to a variable name user in the page scope.


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?

See also:

  • Basic/intermediate JSP/Servlet tutorials
  • Implicit Objects in Expression Language
  • Hidden features of JSP/Servlet
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号