Spring MVC请求url无效问题思考

版权声明:本文为博主原创文章,纯粹自娱。 https://blog.csdn.net/moakun/article/details/86505779

一、Controller没有配置

page not found or method not supported.

没有扫描到包里面的controller类

<context:component-scan base-package="com.mk.controller" />

二、请求方式GET/POST

org.springframework.web.servlet.PageNotFound noHandlerFound

 No mapping found for HTTP request with URI [/api/test/c] in DispatcherServlet with name 'dispatcher'

使用了RequestMethod.POST,Http的get请求无法响应

    @RequestMapping(value = "/api/test/c",method = RequestMethod.POST)
    @ResponseBody
    public String bbx(){

        return "bb";
    }

三、Spring MVC中web.xml的url前缀

HTTP Status 405 - Request method 'GET' not supported

web.xml

	<servlet-mapping>
		<servlet-name>springMVC</servlet-name>
		<url-pattern>/api/*</url-pattern>
	</servlet-mapping>

四、参数基本类型数据为null值

    @RequestMapping(value = "/test/a.do")
    @ResponseBody
    public String getA(int a){

        return "AA";
    }

猜你喜欢

转载自blog.csdn.net/moakun/article/details/86505779