How to output HTML from JSP <%! … %> block?

前端 未结 8 842
温柔的废话
温柔的废话 2020-12-01 10:25

I just started learning JSP technology, and came across a wall.

How do you output HTML from a method in <%! ... %> JSP declaration block?

This do

8条回答
  •  天命终不由人
    2020-12-01 10:58

    A simple alternative would be the following:

    <%!
        String myVariable = "Test";
        pageContext.setAttribute("myVariable", myVariable);
    %>
    
    
    

    ${myVariable}

    The you could simply use the variable in any way within the jsp code

提交回复
热议问题