0

我正在使用带有通配符的spring 3 mvc Tiles,并且确实获取了参数的值。我已经定义了我的观点:

<definition name="recurso/*/*" extends="genericTemplate">
    <put-attribute name="titulo" value="Recurso" />
    <put-attribute name="body">
        <definition extends="dosColumnasTemplate" >
            <put-attribute name="izquierda" value="/WEB-INF/views/recursos/detalle/{1}.jsp" />
            <put-attribute name="derecha" value="/WEB-INF/views/recursos/detalle/{2}.jsp" />
        </definition>
    </put-attribute>
</definition>

该方法调用处理程序:

@RequestMapping(value="/recurso/{id}", method = RequestMethod.GET)
public String printRecurso(@PathVariable(value = "id") Long id, ModelMap model)
{
  model.addAttribute("active", "recursos");
  return "recurso/campos/grupos";
}

我正在使用 TilesView:

<!-- Tiles View Url Based Resolver -->
<bean id="tilesViewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
       <property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" />
</bean>

结果出现如下错误: El Servlet.service() for servlet jsp throw exception javax.servlet.ServletException: JSP File "/WEB-INF/views/recursos/detalle/jsp {1}." 未找到

javax.servlet.ServletException:JSP 文件“/WEB-INF/views/recursos/detalle/jsp {2}。” 未找到

4

2 回答 2

0

我的 pom.xml

<modelVersion>4.0.0</modelVersion>
<groupId>es.omb</groupId>
<artifactId>recursos</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>recursos Maven Webapp</name>
<url>http://maven.apache.org</url>

<properties>
    <spring.version>3.2.10.RELEASE</spring.version>
    <tiles.version>3.0.4</tiles.version>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-extras</artifactId>
        <version>${tiles.version}</version>
    </dependency>   

    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

</dependencies>
<build>
    <finalName>recursos</finalName>
</build>

我的调度员:

<context:component-scan base-package="es.omb.recursos.controllers" />

<!-- Spring Internal View Resolver -->
<!-- 
<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix">
        <value>/WEB-INF/views/</value>
    </property>
    <property name="suffix">
        <value>.jsp</value>
    </property>
</bean>
-->

<!-- Tiles Configuration --> 
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/tiles/templates.xml</value>
            <value>/WEB-INF/tiles/recursos.xml</value>
            <value>/WEB-INF/tiles/duplicados.xml</value>
            <value>/WEB-INF/tiles/tipoloxias.xml</value>
            <value>/WEB-INF/tiles/campos.xml</value>
        </list>
    </property>
</bean>

<!-- Tiles View Url Based Resolver -->
<bean id="tilesViewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
       <property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" />
</bean>


<!-- Recursos estáticos css y js -->
<mvc:annotation-driven />
<mvc:resources mapping="/assets/**" location="/assets/" />

我的瓷砖配置模板.xml:

<!-- Plantilla genérica con el menú, body y footer -->
<definition name="genericTemplate" template="/WEB-INF/views/templates/template.jsp">
    <put-attribute name="menu" value="/WEB-INF/views/templates/menus/superior.jsp" />
    <put-attribute name="footer" value="/WEB-INF/views/templates/footer.jsp" />
</definition>

<!-- Plantilla genérica del body de una columna -->
<definition name="unaColumnaTemplate" template="/WEB-INF/views/templates/body/una-columna.jsp">
</definition>

<!-- Plantilla genérica del body de dos columnas -->
<definition name="dosColumnasTemplate" template="/WEB-INF/views/templates/body/dos-columnas.jsp">
</definition>

<!-- Plantilla genérica del body de tres columnas -->
<definition name="tresColumnasTemplate" template="/WEB-INF/views/templates/body/tres-columnas.jsp">
</definition>   

<definition name="recurso/*/*" extends="genericTemplate">
    <put-attribute name="titulo" value="Recurso" />
    <put-attribute name="body">
        <definition extends="dosColumnasTemplate" >
            <put-attribute name="izquierda" value="/WEB-INF/views/recursos/detalle/{1}.jsp" />
            <put-attribute name="derecha" value="/WEB-INF/views/recursos/detalle/{2}.jsp" />
        </definition>
    </put-attribute>
</definition>           

于 2014-08-01T07:36:06.580 回答
0

似乎此链接中提到的一些罐子问题

  • 瓷砖-api 3.0.1 罐子
  • 瓷砖核心 3.0.1 罐子
  • 瓷砖-jsp 3.0.1 罐子
  • 瓷砖请求 api 1.0.1 jar
  • 公共消化器 2.0 罐
  • commons-beanutils 1.8.0 jar
于 2014-07-31T18:20:32.320 回答