问题如下:
通过验证得知该方法可以进入Controller中处理:
控制台可以正常输出账号跟密码。
但是:但是:但是:
页面跳转时无法进入
success: function (res) {
console.log("res是这个"+res)
if (res.code == 100) {
//登入成功的提示与跳转
layer.msg('登入成功', {
offset: '15px'
, icon: 1
, time: 1000
}, function () {
location.href = '${APP_PATH}/login/toMain.html'; //后台主页
});
} else if (res.code == 200) {
verifyCode = new GVerify("v_container");
layer.msg('用户名或密码错误', {
offset: '15px'
, icon: 2
, time: 1000
});
} else {
layer.msg('未知错误', {
offset: '15px'
, icon: 2
, time: 1000
});
}
}
以下为验证:
解决办法:
在spring-mvc.xml配置文件中写入以下配置
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/>
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="mediaTypes">
<map>
<entry key="html" value="application/json;charset=UTF-8"/>
</map>
</property>
</bean>
结论:其实我现在也还不知道是什么原因,希望有明白的大佬给我解释一下…查找网上说是什么拦截路径为*.html伪静态化后,浏览器会默认为该路径为静态页面,并进行优化,json数据就无法返回到页面。然后加上那个之后此时若*.html请求路径中有json请求,会将响应头的类型改为application/json…讲道理 有点看不懂…