UrlFilenameViewController does not return View (Spring-MVC)
来源:互联网 发布:费列罗巧克力淘宝 编辑:程序博客网 时间:2024/06/07 19:48
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
/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 BeanNameUrlHandlerMapping
which will only do what you want if you bind your controller bean under the name matching your URI. You probably want theSimpleUrlHandlerMapping
instead:
<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>
- UrlFilenameViewController does not return View (Spring-MVC)
- MVC return View("")问题
- spring mvc java.lang.IllegalArgumentException: "undefined" does not contain '/'
- Spring MVC Return
- Spring之AOP奇葩报错:Null return value from advice does not match primitive return type for
- ASP.NET MVC - Entity Framework - Oracle - ORA-00942: table or view does not exist
- how to configure spring mvc 三 to not return “null” object in json response
- mybatis+spring MVC启动的时候出现Mapped Statements collection does not contain value for
- class path resource [spring-mvc.xml] cannot be opened because it does not exist
- spring mvc view resolver
- spring mvc view-controller
- table or view does not exist -- oracle
- table or view does not exist
- CommandText does not return a result set. 怎么处理
- C++ "new" does not return 0 ("NULL") on failure!
- ADOQuery错误:ADOQuery1:commandtext does not return a result set
- ADOQuery错误:ADOQuery1:commandtext does not return a result set
- aop.AopInvocationException: null return value from advice does not match primitive return type for
- 机器性能监控的一些通用参数
- sublime text 3 中文乱码问题
- timesten升级
- Unable to run app in Simulator(Domain = LaunchServicesErrror, Code = 0)
- Mac上Git的安装与简单使用
- UrlFilenameViewController does not return View (Spring-MVC)
- Mysql中查看表的类型
- unable to locate xxxx package
- 黑马程序员——单例模式的两种实现方法
- AVAudioPlayer,AVPlayer 使用
- TCP send 阻塞与非阻塞
- Nginx官方版本说明##Mainline version&Stable version&Legacy versions
- 关于字符编码
- ASP.NET+ajax智能文件检索(自动完成)