hyljava

Tomcat的跨区域访问

如果在Unity3D中或者Flex中访问tomcat会出现访问协议异常 做下面的配置即可解决



crossdomain.xml 位置 将这两个文件放在tomcat主目录下即 %TOMCAT_HOME%\webapps\ROOT 下可以避免不同项目相互访问资源导致的权限问题。

web访问位置http://your_host:port/crossdomain.xml,成功访问该文件即可。

1.crossdomain.xml

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "./cross-domain-policy.dtd">
<cross-domain-policy> <site-control permitted-cross-domain-policies="all" />
    <allow-access-from domain="*" />
    <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

 2.cross-domain-policy.dtd

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Adobe DTD for cross-domain policy files -->
<!-- Copyright (c) 2008-2009, Adobe Systems Inc. -->

<!ELEMENT cross-domain-policy (site-control?,allow-access-from*,allow-http-request-headers-from*,allow-access-from-identity*)>

<!ELEMENT site-control EMPTY>
<!ATTLIST site-control permitted-cross-domain-policies (all|by-content-type|by-ftp-filename|master-only|none) #REQUIRED>

<!ELEMENT allow-access-from EMPTY>
<!ATTLIST allow-access-from domain CDATA #REQUIRED>
<!ATTLIST allow-access-from to-ports CDATA #IMPLIED>
<!ATTLIST allow-access-from secure (true|false) "true">

<!ELEMENT allow-http-request-headers-from EMPTY>
<!ATTLIST allow-http-request-headers-from domain CDATA #REQUIRED>
<!ATTLIST allow-http-request-headers-from headers CDATA #REQUIRED>
<!ATTLIST allow-http-request-headers-from secure (true|false) "true">

<!ELEMENT allow-access-from-identity (signatory)>

<!ELEMENT signatory (certificate)>

<!ELEMENT certificate EMPTY>
<!ATTLIST certificate fingerprint CDATA #REQUIRED>
<!ATTLIST certificate fingerprint-algorithm CDATA #REQUIRED>

<!-- End of file. -->

 

posted on 2012-07-18 17:36 何云隆 阅读(6333) 评论(0)  编辑  收藏 所属分类: Tomcat


只有注册用户登录后才能发表评论。


网站导航: