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

网站打开慢如何优化wordpress grid

网站打开慢如何优化,wordpress grid,莱芜网页制作公司,网站代码优化所有标签文章目录 响应头添加版本号获取版本号添加响应处理器请求结果 打包项目后缀添加版本号和时间实现打包结果 响应头添加版本号 获取版本号 在 pom.xml 中,在 project.version 下定义版本号 在 application.yml 获取 pom.xml 中 project.version 中的信息 添加响应处…

文章目录

  • 响应头添加版本号
    • 获取版本号
    • 添加响应处理器
    • 请求结果
  • 打包项目后缀添加版本号和时间
    • 实现
    • 打包结果


响应头添加版本号

获取版本号

pom.xml 中,在 project.version 下定义版本号

在这里插入图片描述

application.yml 获取 pom.xmlproject.version 中的信息

在这里插入图片描述

添加响应处理器

完整代码如下:

通过 @Value("${project.version}") 获取 application.yml 中的 project.version,并写入响应头

import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;@ControllerAdvice
public class GlobalResponseBodyHandler implements ResponseBodyAdvice<Object> {@Value("${project.version}")private String version;@Overridepublic boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {return true;}@Overridepublic Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {ServletServerHttpResponse ssResp = (ServletServerHttpResponse) response;HttpServletResponse resp = ssResp.getServletResponse();resp.setHeader("version", StringUtils.isNotEmpty(version) ? version : "unknown");return body;}
}

请求结果

在这里插入图片描述

打包项目后缀添加版本号和时间

实现

pom.xml 中的 build 标签,写入以下代码

<build><!--打包后生成文件名--><finalName>${project.artifactId}-${project.version}_${current.time}</finalName><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><mainClass>com.chh.api.ChhApplication</mainClass><executable>true</executable></configuration></plugin><plugin><groupId>org.codehaus.mojo</groupId><artifactId>build-helper-maven-plugin</artifactId><version>3.0.0</version><executions><execution><id>timestamp-property</id><goals><goal>timestamp-property</goal></goals></execution></executions><configuration><name>current.time</name><pattern>yyyyMMdd-HHmmss</pattern><timeZone>GMT+8</timeZone></configuration></plugin><!-- 打包跳过测试--><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><configuration><skip>true</skip></configuration></plugin></plugins>
</build>

打包结果

在这里插入图片描述

http://www.yayakq.cn/news/837069/

相关文章:

  • 建设部网站79号文件网络营销教学大纲
  • wordpress建站更换图片装饰网站建设套餐报价
  • zencart外贸建站如何自己开网站
  • 网站开发外文文献网站做标签
  • 秒速网站建设做 58 那样的网站
  • 阿里巴巴国际站特点wordpress song
  • win7记事本做网站wordpress 中文seo插件
  • 网站开发支付宝支付懒人图库
  • 做系统后之前网站怎么找回wordpress 上传网站
  • 机械设备做公司网站宁波奉化建设局网站
  • 合肥企业网站排名优化创建网站需要备案吗
  • 苏州网站开发公司有哪些深圳seo优化关键词排名
  • 课堂阵地建设网站新乡建设招标投标网站
  • 湖北营销型网站建设多少钱wordpress固定链接 中文
  • wordpress配置文件修改淮北百度seo
  • 阿里云网站的网页怎么做山西省
  • 锦州滨海新区城市建设规划网站网站建设服务费怎么做会计分录
  • 怎么用网站做淘宝客怎么用ps做网站图片
  • 2017网站seo如何做开发一套电商网站多少钱
  • nas可以做网站下载服务器吗乐趣公园 wordpress
  • 网站建设技巧讠金手指排名26策划网站设计
  • 三门峡做网站的公司WordPress分类目录 前100篇
  • 网站开发基础教程买友情链接有用吗
  • 怎样做站长建网站it培训机构排行
  • 海安建设银行网站中国图片素材网
  • 广东网站建设报价官网湖南人文科技学院2021分数线
  • 东莞网站建设排名ccyy切换路线专线
  • 广州大石附近做网站的公司哪家好稳定的网站制作需要多少钱
  • 帝国cms做的网站百度营销推广登录
  • 搜索栏搜索网站?热?文广州市建设工程造价管理站