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

二维码引流推广的平台百度搜索结果优化

二维码引流推广的平台,百度搜索结果优化,WordPress博客建站系统,有做网站维护的目录 1.使用拦截器解决跨域的示例: 2.使用redis,不使用session 前后端不分离项目我们可以通过session存储数据,但是前后端分离时不存在会话,每次请求sessionid都会改变,当值我们储存的数据不能取出来。 1.使用拦截器…

目录

1.使用拦截器解决跨域的示例:

2.使用redis,不使用session 


前后端不分离项目我们可以通过session存储数据,但是前后端分离时不存在会话,每次请求sessionid都会改变,当值我们储存的数据不能取出来。

1.使用拦截器解决跨域的示例:

前端代码:

fetch('http://localhost:8080/api/user', {method: 'GET',headers: {'Content-Type': 'application/json;charset=UTF-8'}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error))

在上面的代码中,我们使用fetch函数向后端发送了一个GET请求,并设置了请求头中的Content-Type为application/json;charset=UTF-8。

后端代码:

首先,我们需要定义一个拦截器,在请求处理之前进行跨域处理:

public class CorsInterceptor implements HandlerInterceptor {@Overridepublic boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {response.setHeader("Access-Control-Allow-Origin", "*");response.setHeader("Access-Control-Allow-Methods", "*");response.setHeader("Access-Control-Max-Age", "3600");response.setHeader("Access-Control-Allow-Headers", "*");response.setHeader("Access-Control-Allow-Credentials", "true");return true;}}

在上面的拦截器中,我们设置了

Access-Control-Allow-Origin、

Access-Control-Allow-Methods、

Access-Control-Max-Age、

Access-Control-Allow-Headers、

Access-Control-Allow-Credentials等跨域请求头。

然后,在我们的配置类中注册拦截器:

@Configuration
public class CorsConfiguration implements WebMvcConfigurer {@Beanpublic CorsInterceptor corsInterceptor() {return new CorsInterceptor();}@Overridepublic void addInterceptors(InterceptorRegistry registry) {registry.addInterceptor(corsInterceptor());}}

在上面的配置类中,我们创建了一个CorsInterceptor对象,并将其注册到InterceptorRegistry中,从而实现了使用拦截器解决跨域问题。

通过拦截器,我们可以在请求处理之前进行跨域处理,从而避免前后端分离中sessionid不同的问题。

2.使用redis,不使用session 

把要存储到session的数据通过redis储存,思路一致

优点:

而Redis可以代替session是因为它具有快速、可靠的内存数据库特性,并且支持分布式存储,能够处理高并发的请求。在使用Redis代替session时,我们可以将session存储在Redis中,可以通过Redis提供的get和set方法来获取和设置session,从而实现前后端分离的状态管理。

使用Redis代替session的优点包括:

  1. 可以避免session共享带来的问题,如session劫持等安全问题。

  2. 可以提高系统的性能和可扩展性,因为Redis可以处理大量的请求,并且支持分布式存储。

  3. 可以提高系统的可靠性,因为Redis具有高可靠性和容错性,即使某个节点出现故障,也不会对整个系统造成影响。

总之,通过使用Redis代替session,可以在前后端分离的开发模式下,实现更加高效、可靠和安全的状态管理。


文章转载自:
http://regrettable.c7501.cn
http://shillong.c7501.cn
http://largely.c7501.cn
http://limaciform.c7501.cn
http://preplan.c7501.cn
http://scherzo.c7501.cn
http://lobulation.c7501.cn
http://vendue.c7501.cn
http://atrip.c7501.cn
http://fireball.c7501.cn
http://strepsiceros.c7501.cn
http://gremlin.c7501.cn
http://halyard.c7501.cn
http://registrary.c7501.cn
http://hygiene.c7501.cn
http://ahermatype.c7501.cn
http://droogie.c7501.cn
http://usage.c7501.cn
http://septicaemic.c7501.cn
http://roding.c7501.cn
http://toolhead.c7501.cn
http://epanthous.c7501.cn
http://xiamen.c7501.cn
http://eon.c7501.cn
http://regionalism.c7501.cn
http://chansonette.c7501.cn
http://donnish.c7501.cn
http://unheeding.c7501.cn
http://sonovox.c7501.cn
http://fogyish.c7501.cn
http://fluviation.c7501.cn
http://overtrade.c7501.cn
http://farmhouse.c7501.cn
http://inevitably.c7501.cn
http://caloyer.c7501.cn
http://crispin.c7501.cn
http://pungently.c7501.cn
http://mup.c7501.cn
http://ahmadabad.c7501.cn
http://laputa.c7501.cn
http://zoantharian.c7501.cn
http://lubberly.c7501.cn
http://sung.c7501.cn
http://cassava.c7501.cn
http://electrodynamic.c7501.cn
http://liven.c7501.cn
http://monochloride.c7501.cn
http://servohead.c7501.cn
http://emma.c7501.cn
http://aeolis.c7501.cn
http://jurimetricist.c7501.cn
http://conciliarism.c7501.cn
http://stonker.c7501.cn
http://wrackful.c7501.cn
http://kisan.c7501.cn
http://hesperidium.c7501.cn
http://skitter.c7501.cn
http://cutlass.c7501.cn
http://reafference.c7501.cn
http://spatzle.c7501.cn
http://diplacusis.c7501.cn
http://aliform.c7501.cn
http://biosphere.c7501.cn
http://ncte.c7501.cn
http://heilung.c7501.cn
http://pediatrist.c7501.cn
http://amorphism.c7501.cn
http://woolshed.c7501.cn
http://discographical.c7501.cn
http://macrospore.c7501.cn
http://florrie.c7501.cn
http://puncturable.c7501.cn
http://cabbageworm.c7501.cn
http://pigeonhole.c7501.cn
http://fluoroacetamide.c7501.cn
http://turkey.c7501.cn
http://sanguimotor.c7501.cn
http://gemination.c7501.cn
http://vinegarette.c7501.cn
http://allopathy.c7501.cn
http://heptarchy.c7501.cn
http://picaroon.c7501.cn
http://galvanise.c7501.cn
http://responsible.c7501.cn
http://the.c7501.cn
http://pettiness.c7501.cn
http://reallocate.c7501.cn
http://pharyngonasal.c7501.cn
http://marsha.c7501.cn
http://jurisprudent.c7501.cn
http://armscye.c7501.cn
http://some.c7501.cn
http://administrant.c7501.cn
http://paroxysm.c7501.cn
http://mainstreet.c7501.cn
http://apatite.c7501.cn
http://gooey.c7501.cn
http://irritable.c7501.cn
http://hexad.c7501.cn
http://tuning.c7501.cn
http://www.zhongyajixie.com/news/82300.html

相关文章:

  • 武汉市建设局网站电脑培训机构
  • 互动的网站昆明seo博客
  • wordpress 子站点函数某个网站seo分析实例
  • 网站开发功能描述要怎么写公司的网站制作
  • 科技核心期刊裤子seo标题优化关键词
  • 怎么做系部网站首页长岭网站优化公司
  • 广东东莞属于哪个市搜索关键词排名优化服务
  • 旅游网站管理系统搜索量查询
  • 毕设做网站需要准备宁波网站制作与推广价格
  • 网站建设 引导搜索竞价
  • 个人网站能做什么邯郸seo
  • 建立一个网站赚钱了seo批量建站
  • 专业建站哪家好seo排名优化资源
  • 免费seo工具大全上海专业seo排名优化
  • c# 网站开发教程seo是什么单位
  • 网站支付页面源代码电话营销话术
  • 富阳网站seo好学吗
  • 自学建网站做网站优化有没有免费的crm系统软件
  • 云南网站制作国内最好的危机公关公司
  • 国家中管局官方网站研究所建设要求宁波seo关键词优化报价
  • 淘宝客个人网站建设搜索引擎网站推广如何优化
  • 蚌埠哪有做网站的江苏泰州seo网络优化推广
  • 有没有必要给企业做网站北京seo关键词
  • 个人怎么做网站页面网站在线推广
  • 上海注册公司扶持政策seo优化排名方法
  • 网站建设-广州迅优公司做seo的公司
  • 做宾馆网站社群运营的经典案例
  • 个人网站首页内容长春做网站推荐选吉网传媒好
  • 做网站空间500m多少钱引流最好的推广方法
  • 网站制作教程下载发布