尝试打开URL http://localhost:8080/app/clientes/agregar时遇到以下异常:
javax.servlet.ServletException: Could not resolve view with name 'clientes/agregar' in servlet with name 'Spring MVC Dispatcher Servlet'
我的mvc-config.xml是以下内容:
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions" value="/WEB-INF/tiles/tiles.xml" />
</bean>
我简单的tile.xml:
<definition name="mainTemplate" template="/WEB-INF/template/template.jsp">
<put-attribute name="titulo" value="Simple Tiles 2 Example" type="string" />
<put-attribute name="header" value="/WEB-INF/template/header.jsp" />
<put-attribute name="footer" value="/WEB-INF/template/footer.jsp" />
</definition>
<definition name="*" extends="mainTemplate">
<put-attribute name="content" value="/WEB-INF/views/{1}.jsp" />
</definition>
当我尝试打开/ app下的位置时,它可以正常工作,例如/ app / welcome或/ app / clientes,但是尝试打开/ app / clientes / something时会出现此错误.我想这与URL解析器有关,但我找不到…
用@Controller注释的我的ClientesController类具有如下方法:
@RequestMapping(method = RequestMethod.GET,value = "agregar")
public void agregar() { ... }
我的JSP视图文件位于/ WEB-INF / views下,例如:
/WEB-INF/views
-- /clientes
---- agregar.jsp
-- welcome.jsp
-- clientes.jsp
谢谢!
最佳答案