spring mvc 拦截 后 ajax请求 获取不到session

spring mvc 拦截 后 ajax请求 获取不到session,第1张

你的意思是AJAX访问被上面拦截器拦截之后获取不到session吧?

把AJAX访问代码贴出来看看,除非是脚本代码写得不兼容,要不然怎么只有火狐下不能访问呢。你可以用firefox下的firebug,进行断点调试,很好用。

打开mvc项目的csproj文件:

<MvcBuildViews>false</MvcBuildViews>

改为

<MvcBuildViews>true</MvcBuildViews>

springmvc的配置文件中对freemarker配置如下:

<bean

id="viewResolver"

class="orgspringframeworkwebservletviewfreemarkerFreeMarkerViewResolver">

<property

name="viewClass"

value="orgspringframeworkwebservletviewfreemarkerFreeMarkerView"

/>

<property name="suffix" value="html" />

<property

name="contentType" value="text/html;charset=utf-8" />

<property

name="exposeRequestAttributes" value="true" />

<property

name="exposeSessionAttributes" value="true" />

<property

name="exposeSpringMacroHelpers" value="true" />

<!--

此变量值为pageContextrequest, 页面使用方法:rccontextPath -->

<property

name="requestContextAttribute" value="rc" />

</bean>

是这样方式:

${Session["user"]}

~如果你认可我的回答,请及时点击采纳为满意回答按钮

~~手机提问的朋友在客户端右上角评价点满意即可。

~你的采纳是我前进的动力

~~O(∩_∩)O,记得好评和采纳,互相帮助,谢谢。

如果你登录用户存进session里面了。直接从session里面取就可以。

requestgetSession()getAttribute("userinfo");

望采纳

<property name="exposeSessionAttributes" value="true" />

然后就可以直接访问了,session中的对象已经合并进页面上下文了

以上就是关于spring mvc 拦截 后 ajax请求 获取不到session全部的内容,包括:spring mvc 拦截 后 ajax请求 获取不到session、MVC cshtml 怎样使用Session、.netmvc同一浏览器sessionid等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9303597.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存