在mvc Web应用程序中允许跨域脚本 [英] Allow cross domain scripting in mvc web application

查看:415
本文介绍了在mvc Web应用程序中允许跨域脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web应用程序和im使用spring mvc。
我需要允许跨域脚本(我需要一个web服务,外部化可以通过javascript访问)。
我写了一个crossdomain.xml,我把它放在WEB-INF文件夹下。这是我的crossdomain.xml

I have a web application and im using spring mvc. I need to allow cross domain scripting (i need that a web service that i externalize can be accessed by javascript). I wrote a crossdomain.xml and i put it under the WEB-INF folder. This is my crossdomain.xml

<?xml version="1.0" encoding="UTF-8"?>
<cross-domain-policy>
  <allow-access-from domain="*" />
</cross-domain-policy>

我已经搜索过,看到crossdomain.xml应该可以从这个URL访问:
localhost:8080 / crossdomain.xml
的事情是mvc将请求重新路由到主控制器(使用RequestMapping注释/)。我如何克服这个使用spring mvc?

谢谢。

I have searched around and saw that the crossdomain.xml should be accessable from this URL: "localhost:8080/crossdomain.xml"
the thing is that the mvc is rerouting the request to the main controller (with RequestMapping annotation of "/"). How can i overcome this using spring mvc?
Thank you.

推荐答案

在jax rs泽西实现和春天之间。所有在此博客中解释
Jersey Spring集成

There is a special integration between jax rs jersey implementation and spring. all explained in this blog Jersey Spring integration

这篇关于在mvc Web应用程序中允许跨域脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆