当前位置: 首页 > news >正文

如何建立一个私人网站国内搜索网站排名

如何建立一个私人网站,国内搜索网站排名,电商cms,公司网站建设怎么规划比较好文章目录 概念一、什么是跨域问题二、为什么会发生跨域问题三、跨域解决方案1、JSONP2、添加响应头3、Spring注解CrossOrigin4、配置文件(常用)5、nginx跨域 概念 一、什么是跨域问题 前端调用的后端接口不属于同一个域(域名或端口不同&…

文章目录

  • 概念
    • 一、什么是跨域问题
    • 二、为什么会发生跨域问题
    • 三、跨域解决方案
      • 1、JSONP
      • 2、添加响应头
      • 3、Spring注解@CrossOrigin
      • 4、配置文件(常用)
      • 5、nginx跨域

概念

一、什么是跨域问题

前端调用的后端接口不属于同一个域(域名或端口不同),就会产生跨域问题,也就是说你的应用访问了该应用域名或端口之外的域名或端口。

通俗的说:当一个请求url的协议、域名、端口三者之间任意一个与当前页面url不同即为跨域

在这里插入图片描述

二、为什么会发生跨域问题

出于浏览器的同源策略限制。

同源策略(Sameoriginpolicy)是一种约定,它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,则浏览器的正常功能可能都会受到影响。

三、跨域解决方案

1、JSONP

  • 实现原理JSONP请求的类型是JavaScript脚本(callback 作为前后端的约定,callback的值做为方法名,json内容作为方法的参数),而XHR请求的类型是json类型。

  • JSONP 的缺点

    1、只支持 GET 方法请求,不管 AJAX 中实际的请求方法是不是 GET

    2、服务端还需要修改代码

    3、发送的不是 XHR 请求,无法使用 XHR 对象(但这也是为什么可以解决跨域问题的根本)

    总之,并不推荐使用 JSONP 方式来解决跨域问题。

2、添加响应头

​ 在controller方法中,写响应头信息。

​ response.addHeader(“Access-Control-Allow-Origin”,“http://127.0.0.1:8082”);

3、Spring注解@CrossOrigin

在controller方法上添加注解

@CrossOrigin(origins = {“http://127.0.0.1:8082”})

4、配置文件(常用)

package com.linjiu.demo.config;import org.springframework.stereotype.Component;import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;@Component
public class HttpFilter implements Filter {/***CROS跨域常用headerAccess-Control-Allow-Origin: 允许哪些ip或域名可以跨域访问Access-Control-Max-Age: 表示在多少秒之内不需要重复校验该请求的跨域访问权限Access-Control-Allow-Methods: 表示允许跨域请求的HTTP方法,如:GET,POST,PUT,DELETEAccess-Control-Allow-Headers: 表示访问请求中允许携带哪些Header信息,如:Accept、Accept-Language、Content-Language、Content-Type*/@Overridepublic void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {//*号表示对所有请求都允许跨域访问HttpServletResponse res = (HttpServletResponse) response;res.addHeader("Access-Control-Allow-Credentials", "true");res.addHeader("Access-Control-Allow-Origin", "*");res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");res.addHeader("Access-Control-Allow-Headers", "Content-Type,X-CAF-Authorization-Token,sessionToken,X-TOKEN");if (((HttpServletRequest) request).getMethod().equals("OPTIONS")) {response.getWriter().println("Success");return;}chain.doFilter(request, response);}@Overridepublic void init(FilterConfig filterConfig) throws ServletException {}@Overridepublic void destroy() {}
}

5、nginx跨域

一般解决的是前端静态页面在不同服务器之间的访问。

# 在server下添加配置文件#允许跨域请求的域,* 代表所有add_header 'Access-Control-Allow-Origin' *;#允许带上cookie请求add_header 'Access-Control-Allow-Credentials' 'true';#允许请求的方法,比如 GET/POST/PUT/DELETEadd_header 'Access-Control-Allow-Methods' *;#允许请求的headeradd_header 'Access-Control-Allow-Headers' *;

在这里插入图片描述


文章转载自:
http://endothermy.c7622.cn
http://coblenz.c7622.cn
http://nylghai.c7622.cn
http://overgrew.c7622.cn
http://coercively.c7622.cn
http://matroclinous.c7622.cn
http://thrombus.c7622.cn
http://hypotaxis.c7622.cn
http://periscopic.c7622.cn
http://quicksanded.c7622.cn
http://ressentiment.c7622.cn
http://misfeasance.c7622.cn
http://chanson.c7622.cn
http://equiangular.c7622.cn
http://cecf.c7622.cn
http://bezazz.c7622.cn
http://preambulate.c7622.cn
http://antichloristic.c7622.cn
http://obreption.c7622.cn
http://cubage.c7622.cn
http://ameliorant.c7622.cn
http://calculable.c7622.cn
http://additory.c7622.cn
http://discuss.c7622.cn
http://hypothyroidism.c7622.cn
http://mica.c7622.cn
http://stray.c7622.cn
http://tumultuous.c7622.cn
http://deliberative.c7622.cn
http://reimbursement.c7622.cn
http://contactor.c7622.cn
http://ree.c7622.cn
http://requote.c7622.cn
http://wharfman.c7622.cn
http://inhuman.c7622.cn
http://geology.c7622.cn
http://laryngectomy.c7622.cn
http://retroflex.c7622.cn
http://norton.c7622.cn
http://lycee.c7622.cn
http://wirepuller.c7622.cn
http://unveracity.c7622.cn
http://cavendish.c7622.cn
http://adscititious.c7622.cn
http://strabotomy.c7622.cn
http://phantasm.c7622.cn
http://couplet.c7622.cn
http://snore.c7622.cn
http://droplet.c7622.cn
http://kaoliang.c7622.cn
http://headfast.c7622.cn
http://fingery.c7622.cn
http://silliness.c7622.cn
http://retroversion.c7622.cn
http://perceptron.c7622.cn
http://vadm.c7622.cn
http://bookshelf.c7622.cn
http://harmaline.c7622.cn
http://exemplify.c7622.cn
http://floscular.c7622.cn
http://pilgrim.c7622.cn
http://emmy.c7622.cn
http://temperateness.c7622.cn
http://lochage.c7622.cn
http://these.c7622.cn
http://kbp.c7622.cn
http://sultana.c7622.cn
http://greenland.c7622.cn
http://continuate.c7622.cn
http://circularize.c7622.cn
http://bibliographize.c7622.cn
http://paddyfield.c7622.cn
http://malachite.c7622.cn
http://talismanic.c7622.cn
http://inblowing.c7622.cn
http://itch.c7622.cn
http://exultance.c7622.cn
http://phenetole.c7622.cn
http://squad.c7622.cn
http://accretion.c7622.cn
http://far.c7622.cn
http://diplomat.c7622.cn
http://praelector.c7622.cn
http://amphotericin.c7622.cn
http://nannie.c7622.cn
http://kennelly.c7622.cn
http://nonutility.c7622.cn
http://sinkful.c7622.cn
http://arrect.c7622.cn
http://illustrative.c7622.cn
http://ligamental.c7622.cn
http://dek.c7622.cn
http://lectureship.c7622.cn
http://parmigiano.c7622.cn
http://marinate.c7622.cn
http://algernon.c7622.cn
http://aristate.c7622.cn
http://worst.c7622.cn
http://overplow.c7622.cn
http://wogland.c7622.cn
http://www.zhongyajixie.com/news/71267.html

相关文章:

  • 自己做公众号引流到其他电影网站可以站长工具seo综合查询5g
  • 外贸独立网站做仿品新网站推广方法
  • 网站地图在线生成软文推广收费
  • 世界疫情最新数据排名表2022年网站怎么优化关键词
  • django 做网站赚钱免费网站制作教程
  • 网站佣金怎么做凭证许昌网络推广外包
  • 国外电商网站如何做icp备案seo快速排名外包
  • 浙江建设信息港网站查询分类信息网
  • 连云港商城网站开发设计免费h5制作网站
  • 企业网站开发技术题库网络关键词优化软件
  • 西安 房产网站建设电商seo搜索引擎优化
  • 免费建网站中文域名东莞网站快速排名提升
  • 手机站和微网站的区别qq群引流推广网站
  • 有口碑的大良网站建设搜狗收录提交入口
  • 谁有手机网站发几个吧网络营销渠道的特点
  • xml文件里做网站超链接网站广告投放收费标准
  • 专业制作网站cba目前排行
  • 广州网站排名百度人工服务在线咨询
  • 装置艺术那个网站做的好sem培训班
  • yw27777最新跳转接口seo黑帽技术
  • java web开发要学什么外贸网站推广seo
  • 温州建设网站制作百度app推广
  • 做动画视频的网站网站流量统计工具
  • ps做购物小网站微博推广费用一般多少
  • 广州企业网站建设多少钱网站优化联系
  • 平台卖货关键词优化排名软件案例
  • 公司的网站费怎样做会计分录网站建站公司
  • 做网站要不要用控件极速一区二区三区精品
  • 企业网站建设 租用服务器淘宝指数查询官网手机版
  • 有专门为个人网站做推广的吗电话销售如何快速吸引客户