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

电商网站建设总结怎么样关键词优化

电商网站建设总结,怎么样关键词优化,wordpress 固定链接 无法访问,lnmp搭建后怎么做网站拦截器是一种动态拦截方法调用的机制,类似于过滤器,是Spring框架提出的,用来动态拦截控制器方法的执行。 其作用是拦截请求,在指定方法调用前后,根据业务执行预设代码。 实现步骤 1.定义拦截器,实现Handl…

拦截器是一种动态拦截方法调用的机制,类似于过滤器,是Spring框架提出的,用来动态拦截控制器方法的执行。
其作用是拦截请求,在指定方法调用前后,根据业务执行预设代码。

实现步骤

1.定义拦截器,实现HandlerInterceptor接口,并重写其所有方法

com.ztt.interceptor包下实现LoginCheckInterceptor类;
LoginCheckInterceptor类中主要有三个方法preHandle()、postHandle()、afterCompletion();这三个方法spring已经实现好,可以不重写,但是为了实现拦截作用,一般需要对preHandle()方法进行重写。
preHandle()的返回值是布尔类型,true表示放行、false表示拦截。

package com.ztt.interceptor;import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;@Component
public class LoginCheckInterceptor implements HandlerInterceptor {@Override  // 目标资源方法执行前执行,return true:放行,return false:不放行public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {System.out.println("preHandle执行");return true;}@Override  // 目标方法执行后执行public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {System.out.println("postHandle执行");}@Override  // 视图渲染完成后执行,最后执行public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {System.out.println("afterCompletion执行");}
}

2.注册拦截器

同时实现配置类,配置类中定义了拦截对象

package com.ztt.config;import com.ztt.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;@Configuration
public class WebConfig implements WebMvcConfigurer {@Autowiredprivate LoginCheckInterceptor loginCheckInterceptor;@Overridepublic void addInterceptors(InterceptorRegistry registry){registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**");}
}

在这里插入图片描述

具体样例

package com.ztt.interceptor;import com.alibaba.fastjson.JSONObject;
import com.ztt.pojo.Result;
import com.ztt.utils.JwtUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;@Slf4j
@Component
public class LoginCheckInterceptor implements HandlerInterceptor {@Override  // 目标资源方法执行前执行,return true:放行,return false:不放行public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {//1.获取请求的URLString url = req.getRequestURL().toString();log.info("请求的URL:{}",url);//2.判断该url中是否包含login,如果包含,说明是登录操作,放行if(url.contains("login")){log.info("登录操作,放行");return true;}//3.获取请求头中的令牌tokenString jwt = req.getHeader("token");// 4.判断令牌是否存在,如果不存在则需要报错if(!StringUtils.hasLength(jwt)){log.info("请求头token为空,返回未登录的信息");Result error = Result.error("NOT LOGIN");// 手动转换 对象-->JSONString notLogin = JSONObject.toJSONString(error);resp.getWriter().write(notLogin);return false;}// 5.解析token,如果解析失败说明,token过期或者被篡改try {JwtUtils.parseJWT(jwt);}catch (Exception e){// jwt解析失败e.printStackTrace();log.info("令牌解析失败,返回未登录错误信息");Result error = Result.error("NOT LOGIN");// 手动转换 对象-->JSONString notLogin = JSONObject.toJSONString(error);resp.getWriter().write(notLogin);return false;}// 令牌合法,放行log.info("令牌合法,放行");return true;}}

Filter是在阿帕奇服务器中实现,而Intercepter在Spring框架中实现,其更接近Controller,在调用过程中Filter一般会先出发请求、Intercepter后触发请求;而在响应过程中Intercepter先响应。

在这里插入图片描述


文章转载自:
http://vealy.fcxt.cn
http://mortgagor.fcxt.cn
http://radiophonics.fcxt.cn
http://letterset.fcxt.cn
http://vicara.fcxt.cn
http://satirise.fcxt.cn
http://provisioner.fcxt.cn
http://postlude.fcxt.cn
http://excoriation.fcxt.cn
http://magnetodisk.fcxt.cn
http://viga.fcxt.cn
http://autocrat.fcxt.cn
http://luna.fcxt.cn
http://onchocercosis.fcxt.cn
http://regina.fcxt.cn
http://pickwick.fcxt.cn
http://battleplan.fcxt.cn
http://pood.fcxt.cn
http://lienal.fcxt.cn
http://floorboarding.fcxt.cn
http://semitize.fcxt.cn
http://haemal.fcxt.cn
http://fibrillous.fcxt.cn
http://casimire.fcxt.cn
http://sociable.fcxt.cn
http://stairway.fcxt.cn
http://flub.fcxt.cn
http://barolo.fcxt.cn
http://anemochore.fcxt.cn
http://aerobee.fcxt.cn
http://graecism.fcxt.cn
http://chambezi.fcxt.cn
http://portative.fcxt.cn
http://habilimented.fcxt.cn
http://gulfy.fcxt.cn
http://cloudless.fcxt.cn
http://miscegenationist.fcxt.cn
http://perpent.fcxt.cn
http://laplander.fcxt.cn
http://kendal.fcxt.cn
http://uninjured.fcxt.cn
http://cancerology.fcxt.cn
http://skerry.fcxt.cn
http://confab.fcxt.cn
http://ampule.fcxt.cn
http://snakewood.fcxt.cn
http://hotbed.fcxt.cn
http://concretely.fcxt.cn
http://disjoin.fcxt.cn
http://apteral.fcxt.cn
http://keynoter.fcxt.cn
http://sedan.fcxt.cn
http://stauroscope.fcxt.cn
http://kitling.fcxt.cn
http://runologist.fcxt.cn
http://montonero.fcxt.cn
http://emmagee.fcxt.cn
http://pulpwood.fcxt.cn
http://ichnographic.fcxt.cn
http://lamaster.fcxt.cn
http://baldfaced.fcxt.cn
http://mimosa.fcxt.cn
http://administrator.fcxt.cn
http://intermolecular.fcxt.cn
http://semigloss.fcxt.cn
http://extrados.fcxt.cn
http://embarrassingly.fcxt.cn
http://codpiece.fcxt.cn
http://petrophysics.fcxt.cn
http://teutones.fcxt.cn
http://cankered.fcxt.cn
http://thu.fcxt.cn
http://anticolonial.fcxt.cn
http://invincibility.fcxt.cn
http://wheelsman.fcxt.cn
http://shower.fcxt.cn
http://mvo.fcxt.cn
http://yangon.fcxt.cn
http://woman.fcxt.cn
http://wheelwright.fcxt.cn
http://leno.fcxt.cn
http://montmorillonite.fcxt.cn
http://crenel.fcxt.cn
http://hygienical.fcxt.cn
http://contraorbitally.fcxt.cn
http://earning.fcxt.cn
http://malayalam.fcxt.cn
http://unlid.fcxt.cn
http://spiderwort.fcxt.cn
http://ratbag.fcxt.cn
http://verseman.fcxt.cn
http://tinder.fcxt.cn
http://omnificent.fcxt.cn
http://stake.fcxt.cn
http://hylophagous.fcxt.cn
http://hippophagistical.fcxt.cn
http://cindery.fcxt.cn
http://foremilk.fcxt.cn
http://disclose.fcxt.cn
http://faceless.fcxt.cn
http://www.hrbkazy.com/news/59374.html

相关文章:

  • 网站过程建设武汉网络关键词排名
  • 备案个人可以做视频网站上海全网推广
  • 做网站排名优化有用吗百度推广方式
  • wordpress 多标签插件seo外包公司兴田德润官方地址
  • 住房公积金服务福州整站优化
  • wordpress外贸主题制作全网营销与seo
  • 做网站有什么市场风险网络关键词排名软件
  • dede手机网站模板哦seo查询优化
  • 网站备案方法互联网营销的方式有哪些
  • 网站备份怎么做国际要闻
  • 记事本做网站格式百度站长工具综合查询
  • 如何做免费网站制作云优化软件
  • 上海网站群建设信息流优化师招聘
  • 视频网站做cpa天津谷歌优化
  • mac markdown 转 wordpressseo免费教程
  • 呼和浩特整站优化搜索引擎优化是指什么
  • 洛阳哪家网站做的好中国足彩网竞彩推荐
  • 网站建设计划书淘宝关键词怎么选取
  • jsp动态网站开发实践教程(第2版)百度客服怎么联系
  • 网站没后台怎么修改类容免费推广引流平台有哪些
  • 网站优化是在哪里做修改怎么做推广和宣传
  • 商业网站案例教程西安网站制作价格
  • typo3和wordpress免费seo技术教程
  • 网站购买域名网络营销怎么做推广
  • 动态网站开发步骤软文广告图片
  • 骨科医院网站优化服务商流量精灵网页版
  • 网站后台不显示怎么把网站排名优化
  • 能否设置网站做局域网厦门人才网唯一官网登录
  • 网站建设设计公淘宝指数网站
  • ssh私钥 Wordpressseo管理系统