Resource specification not allowed here for source level below 1.7

Resource specification not allowed here for source level below 1.7

现象:tomcat能正常启动,但打开页面时,出现上面的错误。

原因:就是jsp编译的版本不对。

因为tomcat7默认jsp的编译级别为1.6。参见:Jasper 2 JSP Engine How To

这里写图片描述
解决方法:
修改conf/web.xml

 <servlet>
        <servlet-name>jspservlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServletservlet-class>
        <init-param>
            <param-name>forkparam-name>
            <param-value>falseparam-value>
        init-param>
        <init-param>
            <param-name>xpoweredByparam-name>
            <param-value>falseparam-value>
        init-param>
          <init-param>
            <param-name>compilerSourceVMparam-name>
            <param-value>1.7param-value>
        init-param>
        <init-param>
            <param-name>compilerTargetVMparam-name>
            <param-value>1.7param-value>
        init-param>
        <load-on-startup>3load-on-startup>
    servlet>

重启后生效。

参考:How to set Tomcat 7 source level to Java 7

你可能感兴趣的:(Exception)