建置Access-C運彩 投資 pttontrol-Allo-Origin,解決多域名跨域疑問
項目中為了測試便捷,一般將Access-Control-Allo-Origin建置為*,在項目上線時再改為真理域名。
想法簡樸蠻橫!之后用到一個WangEditot富文本編制器,上傳圖片需求運彩 棒球延長賽確認具體的Access-Control-Allo-Origin,導致在測試圖片上傳性能時較為麻煩。
通過上搜索,找到了解決想法:
1、建置多個可跨域域名數組
2、通過request的getHeader(Origin)獲取origin
3、請願域名屬于可跨域域名數組,將所取的orgin值設給Access-Control-Allo-Origin
跨域域名建置 public static final String[] ALLOW_DOMAIN = { localhost8000, 1921680100 };
HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; String originHeader = reqgetHeader(Origin); if (ArraysasList(ConstantsALLOW_DOMAIN)contains(originHeader)) { ressetHeader(Access-Control-Allo-Origin, originHeader); ressetHeader(Allo, *); ressetHeader(Access-Control-Allo-Methods, POST, GET, PUT, DELETE, OPTIONS); ressetHeader( Access-Control-Allo-Headers, Or2024世足台灣運彩igin, X-Requested-With, Content-Type, Accept, Referer, User-Agent, Authorization, X-Auth-Token); ressetHeader(Access-Control-Max-Age, 3600); 收取跨域的cookie 2024世足冠軍賠率表 ressetHeader(Access-Control-Allo-Credentials, true); if (IEequals(reqgetParameter(type))) { ((HttpServletResponse) response)setHeader( XDomainRequestAlloed, 1); } if (reqgetMethod()toLoerCase()equals(options)) { ressetHeader(Content-ty運彩 獎金計算pe, text); resgetWriter()rite(options OK); return; } }