- 输出(类似print)
<%= %>
复制代码
- 添加脚本片段(就是Java代码)
<%
int sum=0;
for (int i = 0; i <100 ; i++) {
sum=sum+1;
}
out.println("<h1>"+sum+"</h1>");
%>
复制代码
- 嵌入html(总之,只要是属于java代码的部分都需要<% %>,如
<% } %>
)
<%
for (int i = 0; i < 5; i++){
%>
<h1> hello </h1>
<%
}
%>
复制代码
- 在web.xml中配置错误页面
<error-page>
<error-code>404</error-code><!-- 错误代码404 500,,,,, -->
<location>/error.jsp</location><!-- 发生对应错误是需要打开的jsp页面的位置 -->
</error-page>
复制代码
- 引入其它jsp页面
<jsp:include page="index.jsp"></jsp:include>
<h1>还不错</h1>
复制代码