-6ren">
gpt4 book ai didi

java - JSP各种jsp特性的执行顺序

转载 作者:搜寻专家 更新时间:2023-11-01 03:40:33 24 4
gpt4 key购买 nike

我只是想知道jsp提供的各种功能的执行顺序是什么

  • 脚本
  • 标签库
  • 表达语言

最佳答案

除了它们在页面上出现的顺序,即您编写它们的顺序,我认为没有任何执行顺序。

示例:

<%-- 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 类中的编译顺序,那么它取决于 servlet 容器,我认为它不会增加任何理解这一点的值(value)。

如果您只是想知道这些,请告诉我。

关于java - JSP各种jsp特性的执行顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15551191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com