一 属性配置web.xml
<?xml version="1.0" encoding="GBK"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- 关于JSP的配置信息 -->
<jsp-config>
<jsp-property-group>
<!-- 对哪些文件应用配置 -->
<url-pattern>/noscript/*</url-pattern>
<!-- 忽略表达式语言 -->
<el-ignored>true</el-ignored>
<!-- 页面编码的字符集 -->
<page-encoding>GBK</page-encoding>
<!-- 不允许使用Java脚本 -->
<scripting-invalid>true</scripting-invalid>
<!-- 隐式导入页面头 -->
<include-prelude>/inc/top.jspf</include-prelude>
<!-- 隐式导入页面尾 -->
<include-coda>/inc/bottom.jspf</include-coda>
</jsp-property-group>
<jsp-property-group>
<!-- 对哪些文件应用配置 -->
<url-pattern>*.jsp</url-pattern>
<el-ignored>false</el-ignored>
<!-- 页面编码字符集 -->
<page-encoding>GBK</page-encoding>
<!-- 允许使用Java脚本 -->
<scripting-invalid>false</scripting-invalid>
</jsp-property-group>
<jsp-property-group>
<!-- 对哪些文件应用配置 -->
<url-pattern>/inc/*</url-pattern>
<el-ignored>false</el-ignored>
<!-- 页面编码字符集 -->
<page-encoding>GBK</page-encoding>
<!-- 不允许使用Java脚本 -->
<scripting-invalid>true</scripting-invalid>
</jsp-property-group>
</jsp-config>
<context-param>
<param-name>author</param-name>
<param-value>yeeku</param-value>
</context-param>
</web-app>
二 视图
noscript/test1.jsp
<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> 页面配置1 </title>
<meta name="website" content="http://www.crazyit.org" />
</head>
<body>
<h2>页面配置1</h2>
下面是表达式语言输出:<br/>
${1 + 2}
</body>
</html>
test2.jsp
<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> 页面配置2 </title>
<meta name="website" content="http://www.crazyit.org" />
</head>
<body>
<h2>页面配置2</h2>
下面是表达式语言输出:<br/>
${1 + 2}<br/>
下面是小脚本输出:<br/>
<%out.println("hello Java");%>
</body>
</html>
inc/top.jspf
<div style="background-color:#dddddd;font-size:12pt">
<font color="red">隐式导入的页面头</font>
</div>
inc/bottom.jspf
<div style="background-color:#dddddd;font-size:10pt">
<font color="blue">Copyright ©right; 2001-2016.
<a href="http://www.crazyit.org">疯狂Java联盟</a></font>
</div>
三 测试