Spring No mapping found for HTTP request with URI

J2EE 码拜 9年前 (2015-11-08) 1241次浏览
<!-- 启动SpringMVC的注解功能,它会自动注册HandlerMapping、HandlerAdapter、ExceptionResolver的相关实例 -->
	<mvc:annotation-driven />
	<mvc:default-servlet-handler />
	<!-- 启动Spring的组件自动扫描机制 -->
	<context:component-scan base-package="com.usoft.synusn.controller"></context:component-scan>
	<!--通用视图解析器 -->
	<bean id="viewResolverCommon"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/views/" />
		<property name="suffix" value=".jsp" />
		<property name="viewClass"
			value="org.springframework.web.servlet.view.JstlView" />
		<property name="order" value="1" />
	</bean>
<!-- SpringMVC的前端控制器 -->
	<servlet>
		<servlet-name>spring-mvc</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<!-- <param-value>classpath*:applicationcontext-webmvc.xml,classpath*:applicationcontext-freemarker.xml</param-value> -->
			<param-value>classpath*:applicationcontext-web.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>spring-mvc</servlet-name>
		<!-- 由SpringMVC拦截所有请求 -->
		<url-pattern>/</url-pattern>
	</servlet-mapping>
/**
 * freemarker控制器
 * @author
 * 
 */
@Controller
public class FreeMarkerControler {
    
    @RequestMapping("/hello")
    public String sayHello(ModelMap map) {
        System.out.println("say Hello ……");
        map.addAttribute("message", "Hello World,FreeMarker!");
        return "test";
    }
}

这是我的配置文件和controller,我没发现有什么错误,可总是 No mapping found for HTTP request with URI

解决方案:50分
改为<url-pattern>/*</url-pattern>试下。
解决方案:10分
 <property name=”prefix” value=”/WEB-INF/views/” />这里最后又/
@RequestMapping(“/hello”)//这里就应该是hello,不应该要/了。
解决方案:10分
多视图要配置多个DispatcherServlet才行。
当然不正常。没有部署好
解决方案:10分
http://www.cnblogs.com/penguin-panda/archive/2011/07/09/2101880.html

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Spring No mapping found for HTTP request with URI
喜欢 (0)
[1034331897@qq.com]
分享 (0)