SpringMVC基础框架代码及一些报错小结

目录

1. SpringMVC基础框架回顾

2. 常见报错即解决方式

场景为使用jetty作为web容器。使用tomcat,则不必做手动添加相关依赖等处理。

2.1 嵌入jetty,jsp支持报错

2.1.1 JSP support not configured

JSP support not configured

解决: 检查pom文件是否有相关依赖,如果没有则添加。注意使用9.3.0.M1版本不行。使用release版本可以,如:

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-jsp</artifactId>
            <version>9.2.26.v20180806</version>
        </dependency>

更新依赖包后,问题解决。

2.1.2 PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved

org.apache.jasper.JasperException: /index.jsp(1,63) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core

解决: taglib加上_rt

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

更新成

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>

更新taglib后,问题解决。

2.1.3 可能的报错:jetty web javax.el.ExpressionFactory.newInstance()Ljavax/el/ExpressionFactory

解决:更新jsp-api版本。例如从2.1改为2.2

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.2</version>
        </dependency>

jetty jsp相关maven地址:

 <!-- web容器-->
        <!-- jetty -->
        <dependency>
            <groupId>org.eclipse.jetty.aggregate</groupId>
            <artifactId>jetty-all</artifactId>
            <version>${jetty.version}</version>
            <type>pom</type>
        </dependency>
        <!-- jsp支持-->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-jsp</artifactId>
            <version>9.2.26.v20180806</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.2</version>
        </dependency>

        <!-- 引入servlet -->
        <!--<dependency>-->
            <!--<groupId>javax.servlet</groupId>-->
            <!--<artifactId>javax.servlet-api</artifactId>-->
            <!--<version>3.1.0</version>-->
        <!--</dependency>-->

猜你喜欢

转载自www.cnblogs.com/eaglediao/p/9557719.html