Are methods legal inside JSP scriptlet?

前端 未结 2 1864
陌清茗
陌清茗 2021-02-03 20:11

I know its not recommended, and I should be using tag libraries etc etc.

But I\'d still like to know if it is legal to declare methods in a JSP scriplet:



        
2条回答
  •  醉梦人生
    2021-02-03 20:42

    You need to use declaration syntax (<%! ... %>):

    <%! 
       public String doSomething(String param) { 
          // 
       } 
    %>
    <%
       String test = doSomething("test"); 
    %> 
    

提交回复
热议问题