UrlFilenameViewController does not return View (Spring-MVC)
2015-03-18 13:52
330 查看
According to Spring framework API
UrlFilenameViewController's purpose is:
Transforms the virtual path of a URL into a view name and returns that view
If i request for /info.xhtml, its logical view name is info
See
UrlFilenameViewController documentation
Both web.xml and controller is mapped according to
My smac app deploys fine.
So, if i request for http://127.0.0.1:8080/smac/info.xhtml, Spring-MVC should return /WEB-INF/output/info.jsp. But i have seen in console the following:
No mapping found for HTTP request with URI [/smac/info.xhtml] in DispatcherServlet with name 'controller'
Could anyone help me ?
regards,
You need to configure a
HandlerMapping. Default one is
UrlFilenameViewController's purpose is:
Transforms the virtual path of a URL into a view name and returns that view
If i request for /info.xhtml, its logical view name is info
See
UrlFilenameViewController documentation
Both web.xml and controller is mapped according to
/WEB-INF/web.xml <?xml version="1.0" encoding="UTF-8"> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>smac</display-name> <servlet> <servlet-name>controller</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>controller</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> </web-app> /WEB-INF/controller-servlet.xml <?xml version="1.0" encoding="UTF-8"> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean class="org.springframework.web.servlet.view.InternalViewResolver"> <property name="prefix" value="/WEB-INF/output/"/> <property name="suffix" value=".jsp"/> </bean> <bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/> </beans>
My smac app deploys fine.
So, if i request for http://127.0.0.1:8080/smac/info.xhtml, Spring-MVC should return /WEB-INF/output/info.jsp. But i have seen in console the following:
No mapping found for HTTP request with URI [/smac/info.xhtml] in DispatcherServlet with name 'controller'
Could anyone help me ?
regards,
You need to configure a
HandlerMapping. Default one is
BeanNameUrlHandlerMappingwhich will only do what you want if you bind your controller bean under the name matching your URI. You probably want the
SimpleUrlHandlerMappinginstead:
<bean name="myController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <value> /**/*.xhtml=myController </value> </property> </bean>
相关文章推荐
- SpringMVC—UrlFilenameViewController控制器实现跳转页面
- 如何让 Spring MVC Controller 的同一个 URL 请求,根据逻辑判断返回 JSON 或者 HTML 视图?
- SpringMVC <mvc:view-controller path=""/>标签
- The prefix "mvc" for element "mvc:view-controller" is not bound.
- [转]SpringMVC Controller&View数据传递
- Spring3参考手册 mvc:view-controller
- org.springframework.hateoas.mvc.ControllerLinkBuilder之ClassNotFoundException的错误
- mybatis+spring MVC启动的时候 4000 出现Mapped Statements collection does not contain value for
- ASP.NET MVC - Entity Framework - Oracle - ORA-00942: table or view does not exist
- 报错-Type ViewController doesnot conform to protocol
- Spring参考手册 mvc:view-controller
- The prefix "mvc" for element "mvc:view-controller" is not bound.
- Spring MVC Controller 的同一个 URL 请求,根据逻辑判断返回 JSON 或者 HTML 视图
- Spring MVC Fast Tutorial: Model View Controller
- spring mvc Controller 控制器 url 在html绑定
- springmvc <mvc:view-controller >
- iOS 跳转出现attempt to dismiss modal view controller whose view does not currently ……的解决方案
- mybatis+springMVC整合出现Mapped Statements collection does not contain value for ***
- http://crunchify.com/simplest-spring-mvc-hello-world-example-tutorial-spring-model-view-controller-tips/ 非常棒的spring入门,maven,以及eclipse
- Error using AnnotationMethodHandlerAdapter and UrlFilenameViewController