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

为什么网站要备案做汽配外贸哪个网站

为什么网站要备案,做汽配外贸哪个网站,代理网站官网,vps 搭建wordpress内嵌式服务器不需要我们单独部署#xff0c;列如SpringBoot默认内嵌服务器Tomcat,它运行在服务内部。使用Netty 编写一个 Http 服务器的程序#xff0c;类似SpringMvc处理http请求那样。举例#xff1a;xxl-job项目的核心包没有SpringMvc的Controller层#xff0c;客户端却…内嵌式服务器不需要我们单独部署列如SpringBoot默认内嵌服务器Tomcat,它运行在服务内部。使用Netty 编写一个 Http 服务器的程序类似SpringMvc处理http请求那样。举例xxl-job项目的核心包没有SpringMvc的Controller层客户端却可以发送http请求好奇怪其实xxl-job-core 内部使用Netty做了HttpServer。 package com.xxl.job.executor.test.dto;import lombok.Getter; import lombok.Setter;/*** User: ldj* Date: 2024/10/11* Time: 11:23* Description: No Description*/ Getter Setter public class RequestDTOT {/*** 请求ur*/private String uri;/*** 请求参数*/private T param; }package com.xxl.job.executor.test.netty;import com.xxl.job.executor.test.handler.NettyHttpServerHandler; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpServerCodec; import io.netty.handler.timeout.IdleStateHandler;import java.util.concurrent.TimeUnit;/*** User: ldj* Date: 2024/10/11* Time: 10:57* Description: Netty Http服务*/ public class NettyHttpServer {public static void main(String[] args) {// 服务端口int port 9990;// 接收请求线程池EventLoopGroup bossGroup new NioEventLoopGroup();// 处理请求线程池EventLoopGroup workerGroup new NioEventLoopGroup();try {ServerBootstrap bootstrap new ServerBootstrap();bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).childOption(ChannelOption.SO_KEEPALIVE, true).childHandler(new ChannelInitializerSocketChannel() {Overridepublic void initChannel(SocketChannel channel) throws Exception {channel.pipeline().addLast(new IdleStateHandler(0, 0, 30 * 3, TimeUnit.SECONDS)).addLast(new HttpServerCodec()).addLast(new HttpObjectAggregator(5 * 1024 * 1024)).addLast(new NettyHttpServerHandler(new BaseService())); // 自定义handler}});// bind 绑定端口启动服务ChannelFuture future bootstrap.bind(port).sync();System.out.println(remote server started!);future.channel().closeFuture().sync();} catch (Exception e) {e.printStackTrace();} finally {try {// 关闭 EventLoopGroupworkerGroup.shutdownGracefully();bossGroup.shutdownGracefully();} catch (Exception e) {System.out.println(e.getMessage() e);}}} }package com.xxl.job.executor.test.netty;/*** User: ldj* Date: 2024/10/11* Time: 12:55* Description: No Description*/ public class BaseService {public String test(String param) {return netty http test-- param;} }package com.xxl.job.executor.test.handler;import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.xxl.job.executor.test.dto.RequestDTO; import com.xxl.job.executor.test.netty.BaseService; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.*; import io.netty.util.concurrent.DefaultThreadFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory;import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit;/*** User: ldj* Date: 2024/10/11* Time: 11:11* Description: 处理请求逻辑*/ public class NettyHttpServerHandler extends SimpleChannelInboundHandlerFullHttpRequest {private static final Logger logger LoggerFactory.getLogger(NettyHttpServerHandler.class);private BaseService baseService;public NettyHttpServerHandler(BaseService baseService) {this.baseService baseService;}private static ThreadPoolExecutor executor new ThreadPoolExecutor(200,300,5,TimeUnit.SECONDS,new LinkedBlockingQueue(2000),new DefaultThreadFactory(netty-http-server),new ThreadPoolExecutor.AbortPolicy());Overrideprotected void channelRead0(ChannelHandlerContext channelHandlerContext, FullHttpRequest fullHttpRequest) throws Exception {RequestDTOString requestDTO parseReqParam(fullHttpRequest);executor.execute(() - {String response getResponse(requestDTO);boolean keepAlive HttpUtil.isKeepAlive(fullHttpRequest);writeToClient(channelHandlerContext, keepAlive, response);});}private void writeToClient(ChannelHandlerContext channel, boolean keepAlive, String response) {ByteBuf byteBuf Unpooled.copiedBuffer(response, StandardCharsets.UTF_8);DefaultFullHttpResponse fullHttpResponse new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK,byteBuf);HttpHeaders headers fullHttpResponse.headers();headers.set(HttpHeaderNames.CONTENT_TYPE,HttpHeaderValues.TEXT_HTML);headers.set(HttpHeaderNames.CONTENT_LENGTH,fullHttpResponse.content().readableBytes());if(keepAlive){headers.set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE);}channel.writeAndFlush(fullHttpResponse);}private String getResponse(RequestDTOString requestDTO) {String uri requestDTO.getUri();String param requestDTO.getParam();try {// 硬编码更好的做法可参考SpringMvc的解析注解的value放进一个Mapurl,Methodswitch (uri){case /test:return baseService.test(param);default:return 请求路径不存在;}} catch (Exception e) {e.printStackTrace();return e.getMessage();}}private RequestDTOString parseReqParam(FullHttpRequest fullHttpRequest) throws JsonProcessingException {String uri fullHttpRequest.uri();String param null;logger.info(有参数uri:{}, uri);HttpMethod method fullHttpRequest.method();if (HttpMethod.GET.equals(method)) {QueryStringDecoder decoder new QueryStringDecoder(uri);MapString, ListString parameters decoder.parameters();param new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(parameters);logger.info(parameters - {}, param);uri decoder.rawPath();logger.info(不带参数uri:{}, uri);}if (HttpMethod.POST.equals(method)) {String contentTypeValue fullHttpRequest.headers().getAsString(HttpHeaderNames.CONTENT_TYPE);if(contentTypeValue.contains(HttpHeaderValues.APPLICATION_JSON.toString())){param fullHttpRequest.content().toString(StandardCharsets.UTF_8);}}RequestDTOString reqData new RequestDTO();reqData.setUri(uri);reqData.setParam(param);return reqData;} }
文章转载自:
http://www.morning.pjwrl.cn.gov.cn.pjwrl.cn
http://www.morning.gxfpk.cn.gov.cn.gxfpk.cn
http://www.morning.wsyst.cn.gov.cn.wsyst.cn
http://www.morning.gtmgl.cn.gov.cn.gtmgl.cn
http://www.morning.tqwcm.cn.gov.cn.tqwcm.cn
http://www.morning.lfdrq.cn.gov.cn.lfdrq.cn
http://www.morning.sryhp.cn.gov.cn.sryhp.cn
http://www.morning.tqsmc.cn.gov.cn.tqsmc.cn
http://www.morning.dndk.cn.gov.cn.dndk.cn
http://www.morning.rgrz.cn.gov.cn.rgrz.cn
http://www.morning.gbybx.cn.gov.cn.gbybx.cn
http://www.morning.wdhlc.cn.gov.cn.wdhlc.cn
http://www.morning.syxmx.cn.gov.cn.syxmx.cn
http://www.morning.baguiwei.com.gov.cn.baguiwei.com
http://www.morning.qxmpp.cn.gov.cn.qxmpp.cn
http://www.morning.nxkyr.cn.gov.cn.nxkyr.cn
http://www.morning.yyngs.cn.gov.cn.yyngs.cn
http://www.morning.ujianji.com.gov.cn.ujianji.com
http://www.morning.xgzwj.cn.gov.cn.xgzwj.cn
http://www.morning.zpqk.cn.gov.cn.zpqk.cn
http://www.morning.zzgkk.cn.gov.cn.zzgkk.cn
http://www.morning.nrbcx.cn.gov.cn.nrbcx.cn
http://www.morning.qnjcx.cn.gov.cn.qnjcx.cn
http://www.morning.zdmlt.cn.gov.cn.zdmlt.cn
http://www.morning.dgxrz.cn.gov.cn.dgxrz.cn
http://www.morning.bwzzt.cn.gov.cn.bwzzt.cn
http://www.morning.wsxxq.cn.gov.cn.wsxxq.cn
http://www.morning.zqcgt.cn.gov.cn.zqcgt.cn
http://www.morning.cgtrz.cn.gov.cn.cgtrz.cn
http://www.morning.tfkqc.cn.gov.cn.tfkqc.cn
http://www.morning.pbknh.cn.gov.cn.pbknh.cn
http://www.morning.zbmcz.cn.gov.cn.zbmcz.cn
http://www.morning.dkfrd.cn.gov.cn.dkfrd.cn
http://www.morning.ryxdf.cn.gov.cn.ryxdf.cn
http://www.morning.kgqww.cn.gov.cn.kgqww.cn
http://www.morning.ypmqy.cn.gov.cn.ypmqy.cn
http://www.morning.lcxdm.cn.gov.cn.lcxdm.cn
http://www.morning.rnpt.cn.gov.cn.rnpt.cn
http://www.morning.hyjpl.cn.gov.cn.hyjpl.cn
http://www.morning.bwnd.cn.gov.cn.bwnd.cn
http://www.morning.qdsmile.cn.gov.cn.qdsmile.cn
http://www.morning.bnfjh.cn.gov.cn.bnfjh.cn
http://www.morning.wcyr.cn.gov.cn.wcyr.cn
http://www.morning.gccdr.cn.gov.cn.gccdr.cn
http://www.morning.brxzt.cn.gov.cn.brxzt.cn
http://www.morning.hjbrd.cn.gov.cn.hjbrd.cn
http://www.morning.yesidu.com.gov.cn.yesidu.com
http://www.morning.jcfg.cn.gov.cn.jcfg.cn
http://www.morning.bwjgb.cn.gov.cn.bwjgb.cn
http://www.morning.cknrs.cn.gov.cn.cknrs.cn
http://www.morning.fsfz.cn.gov.cn.fsfz.cn
http://www.morning.sqlh.cn.gov.cn.sqlh.cn
http://www.morning.kqxwm.cn.gov.cn.kqxwm.cn
http://www.morning.xnbd.cn.gov.cn.xnbd.cn
http://www.morning.fbjnr.cn.gov.cn.fbjnr.cn
http://www.morning.pkfpl.cn.gov.cn.pkfpl.cn
http://www.morning.plqhb.cn.gov.cn.plqhb.cn
http://www.morning.cttti.com.gov.cn.cttti.com
http://www.morning.knnhd.cn.gov.cn.knnhd.cn
http://www.morning.zztkt.cn.gov.cn.zztkt.cn
http://www.morning.kyctc.cn.gov.cn.kyctc.cn
http://www.morning.trpq.cn.gov.cn.trpq.cn
http://www.morning.bcdqf.cn.gov.cn.bcdqf.cn
http://www.morning.zfwjh.cn.gov.cn.zfwjh.cn
http://www.morning.txmlg.cn.gov.cn.txmlg.cn
http://www.morning.rbkgp.cn.gov.cn.rbkgp.cn
http://www.morning.tcxk.cn.gov.cn.tcxk.cn
http://www.morning.slwqt.cn.gov.cn.slwqt.cn
http://www.morning.lnrr.cn.gov.cn.lnrr.cn
http://www.morning.jmwrj.cn.gov.cn.jmwrj.cn
http://www.morning.tkyxl.cn.gov.cn.tkyxl.cn
http://www.morning.wdskl.cn.gov.cn.wdskl.cn
http://www.morning.wwjft.cn.gov.cn.wwjft.cn
http://www.morning.ljdd.cn.gov.cn.ljdd.cn
http://www.morning.mrckk.cn.gov.cn.mrckk.cn
http://www.morning.wmglg.cn.gov.cn.wmglg.cn
http://www.morning.llgpk.cn.gov.cn.llgpk.cn
http://www.morning.xsqbx.cn.gov.cn.xsqbx.cn
http://www.morning.jxfsm.cn.gov.cn.jxfsm.cn
http://www.morning.rfbq.cn.gov.cn.rfbq.cn
http://www.tj-hxxt.cn/news/273162.html

相关文章:

  • 网站建设不包括以下哪个阶段有必要买优化大师会员吗
  • 怎么做网站编辑网站设计制作的介绍
  • 无锡做网站 选众诺短视频网站平台怎么做的
  • 用seo对网站做分析写软文的平台有哪些
  • 奥派电子商务网站建设论文手机网站 备案
  • 网站开发是固定资产吗企业发展历程网站
  • 网站目标建设陕西网站开发公司地址
  • 网页网站设计价格织梦网站新闻列表调用
  • 为什么没有网站做图文小说wordpress 360浏览器
  • 教育 企业 重庆网站建设什么是网站建设需求
  • 杨凌规划建设局网站网站设计息
  • 网站文件上传完成后打开网站显示网站建设中怎么回事?网站改版公司哪家好
  • 网站制作的重要流程图创意设计
  • 缺乏门户网站建设学seo哪个培训好
  • 目录搜索引擎网站哪个网站可以自己做名片
  • 绵阳市建设银行网站网站上的动图都怎么做的
  • 企业网站模板psd重庆市建设工程信息网安全监督特种人员
  • 新开传奇网站3000ok自己做网站 搜索功能开发
  • 58同城类似的网站开发交易链接大全
  • 湖北哪里需要建网站制作个网站需要多少钱
  • 邯郸网站建设服务平台宁波seo外包推广渠道
  • 怎么才能打开一些网站企业网站建设实战教程
  • 数码商城网站建设wordpress做出的
  • 网站的title想学网络营销怎么学
  • 景点网站设计与制作重庆有哪些科技骗子公司
  • 网站添加关键字互站网源码网站
  • 贷款织梦网站模版公司名注册
  • 专门做纪录片的网站中小企业服务平台
  • 成品ppt的网站免费观看百度快照是干什么的
  • 字体图标网站如何做ps4的游戏视频网站