spring-mvc 添加controller 请求 200 但是无返回

现象 新增加一个Controller,但在js中调用时报请求200,无请求反馈,重启服务多次,问题依旧。


分析

从问题现象分析:200,无反馈,断点调试未进入。


200

如果是后台写的代码问题,应该是500,而200说明了服务器正常收到并处理了请求,所以先排除controller代码问题:

无反馈

无反馈,断点调试未进入,说明没有进入当前controller代码。

综合以上两点得到的分析是请求被服务器收到,但是被服务器拦截。

处理

spring-mvc.xml中对controller配置了拦截

<mvc:interceptors>
		<mvc:interceptor>
			<!-- 匹配的是url路径, 如果不配置或/**,将拦截所有的Controller -->
			<mvc:mapping path="/**" />
			<mvc:exclude-mapping path="/rest/*"/>
			<mvc:exclude-mapping path="/version/getVersionToWBS/*"/>
			<mvc:exclude-mapping path="/requirement/query/Organization/**"/>
			<bean class="com.cupid.client.interceptor.PermissionFireWall">
				<property name="whitelistPathMatcher" value="${permFirewall.whitelist.pathMatcher}"></property>
				<property name="authorityPathMatcher" value="${permFirewall.authority.pathMatcher}"></property>
			</bean>
		</mvc:interceptor>
	</mvc:interceptors>

添加拦截排除:

<mvc:exclude-mapping path="/rest/*"/>
			<mvc:exclude-mapping path="/version/getVersionToWBS/*"/>
			<mvc:exclude-mapping path="/requirement/query/Organization/**"/>
即可。



猜你喜欢

转载自blog.csdn.net/lxlmycsdnfree/article/details/80246763