找不到文件.jspx。将Spring从3.0升级到4.3并将Tiles 2升级到Tiles 3

时间:2019-02-21 09:04:06

标签: java spring jsp tiles jspx

我正在从Spring 3.0迁移到Spring 4.3.22.RELEASE,并且没有任何问题。现在我正在从Tiles 2迁移到Tiles 3。

<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-jsp</artifactId>
    <version>3.0.8</version>
</dependency>
<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-core</artifactId>
    <version>3.0.8</version>
</dependency>
<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-api</artifactId>
    <version>3.0.8</version>
</dependency>
<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-servlet</artifactId>
    <version>3.0.8</version>
</dependency>

当我在tomcat 7.0.69中发动战争并通过打开tomcat日志中的错误打开主URL页面时。

javax.servlet.ServletException: File &quot;/WEB-INF/views/index.jspx&quot; not found
    at org.apache.jasper.servlet.JspServlet.handleMissingResource(JspServlet.java:417)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:384)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)

我的带有Tiles 3的webmvc-config.xml代码部分是

<bean class="org.springframework.js.ajax.AjaxUrlBasedViewResolver" id="tilesViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"/>
    <property name="order" value="10"/>
    <property name="cache" value="true"/>
</bean>

<bean class="org.springframework.web.servlet.view.tiles3.TilesConfigurer" id="tilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/layouts/layouts.xml</value>
            <value>/WEB-INF/views/views.xml</value>
            <value>/WEB-INF/views/**/views.xml</value>
        </list>
    </property>
</bean>

来自错误的/WEB-INF/views/index.jspx放置在views.xml中,而views.xml在webmvc-config.xml中定义为值。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE tiles-definitions PUBLIC
        "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
        "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>

    <definition extends="default" name="index">
        <put-attribute name="body" value="/WEB-INF/views/index.jspx"/>
    </definition>
    and others jspx
</tiles-definitions>

来自layouts.xml中定义的views.xml中的默认值

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
        "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
        "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">

<tiles-definitions>
    <definition name="default" template="/WEB-INF/layouts/default.jspx" />
    others definitions
</tiles-definitions>

index.jspx映射导致web.xml文件

<servlet-mapping>
  <servlet-name>jsp</servlet-name>
  <url-pattern>*.jspx</url-pattern>
</servlet-mapping>

0 个答案:

没有答案