4

I was just wondering what is the order of execution of various features been provided by jsp

  • scriplets
  • tag library
  • Expression language
4

1 に答える 1

1

それらがページに表示される順序、つまりあなたがそれらを書いた順序以外の実行順序はないと思います。

サンプル:

<%-- page directive: This would go as the import of the generated class so executes first --%>
<%@ page import="my.foo" %>
<%@ page import="your.foo" %>

<% // this would be second & goes in _jspService method
out.println("This is a sample scriptlet");
%>

<%-- // JSTL Tag: this third (goes in _jspService method) --%>
<c:if test="<%= true %>">
    <%-- // this fourth --%>
    <%= "Sample expression. This will print only after the if is executed ... what! Ofcourse it is obvious :-)" %>
</c:if>

<!-- EL: this fourth (goes in _jspService method) -->
${requestScope}

<% // Scriptlet: this fifth (goes in _jspService method)
if (true) {
%>
This should be printed after the zero of expression language :-)
<!-- (goes in _jspService method) -->
<%
}
%>

// this sixth (goes in _jspService method)
<div>
Just some HTML element to make is more interesting.
I wonder I am even answering this question !!
Is it for points ... ssshhhhhh ...
</div>

<%! // Declaration: executes before everything (goes as an instance variable) may be placed before or after the _jspService method depends on the container
boolean declareME = true;
%>

しかし、JSPの要素がJavaクラスでコンパイルされる順序について尋ねている場合、それはサーブレットコンテナに依存しており、それを理解する価値があるとは思いません。

これがあなたが疑問に思っていたすべてであるかどうか教えてください.

于 2013-03-21T16:15:31.563 に答える