How to get JSP scriptlet value in struts tag

前端 未结 2 1894
时光说笑
时光说笑 2021-01-18 19:24

Here is my code:

<% request.setAttribute(\"lcItem\", \"Hello\"); %>

If I do as following, I\'m not getting the value:



        
2条回答
  •  心在旅途
    2021-01-18 20:10

    You can write your code 2 ways

    1. <% request.setAttribute("lcItem", "Hello"); %>
    2. <% pageContext.setAttribute("lcItem", "Hello"); %>

    then if you want to access these values in Struts2 Components you might use #attr. as prefix.

    Example

    Note: It will work fine with request and "pageContext".

     will not work because "lcItem" is not available in the Value Stack.
    

提交回复
热议问题