<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.8</param-value>
</init-param>
默认情况下,Tomcat 8.0采用Java SE 6语言编译JSP,通过上面的设置可以让Tomcat采用Java SE 8的语言特性编译JSP。
配置方法:在Tomcat的安装路径下找到conf目录,打开web.xml文件,找到以下代码块,然后添加上述代码。
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
As of Java EE 7, the only Servlet protocol currently supported is HTTP.
Servlet支持的方法:
Any HTTP Servlet methods you do not override will be responded to with an HTTP status 405 Method Not Allowed error.