java netty工程部署_netty的使用部署

Java Nio教程

http://www.iteye.com/magazines/132-Java-NIO#590

Java线程池的使用

http://www.cnblogs.com/dolphin0520/p/3932921.html

饿了吗netty

https://zhuanlan.zhihu.com/p/30849776

netty websocket JQuery做一个游戏

http://kevinwebber.ca/multiplayer-tic-tac-toe-in-java-using-the-websocket-api-netty-nio-and-jquery/

nettyRPC

https://github.com/luxiaoxun/NettyRpc

netty笔记

https://blog.csdn.net/u013252773/article/list/2

叉叉哥netty mina twisted 教程

http://xxgblog.com/tags/Netty/

netty github

https://github.com/TFdream/netty-tutorials

waylau的essential netty in action

https://waylau.com/essential-netty-in-action

netty一起学

https://blog.csdn.net/linuu/article/category/6167828

netty restful API实现

https://blog.csdn.net/shenzhan168/article/details/53142459

从零开始搭建游戏服务器netty

https://blog.csdn.net/linshuhe1/article/details/53671820

处理耗时业务

https://www.zhihu.com/question/35487154

netty核心概念

https://blog.csdn.net/zero__007/article/details/51295137

netty架构设计

https://blog.csdn.net/tingting256/article/details/52489008

netty简单复杂应用

https://blog.csdn.net/kevindai007/article/details/53588283

netty http服务器

https://blog.csdn.net/huangshanchun/article/details/78302602

分隔符和定长码

https://blog.csdn.net/huangshanchun/article/details/78290746

http://blog.csdn.net/shenzhan168/article/details/53142459

http://blog.csdn.net/d_uanrock/article/details/45621759

教程

http://blog.csdn.net/linshuhe1/article/details/53671820

基础

https://jingyan.baidu.com/article/6079ad0e7e4de128fe86db40.html

https://www.cnblogs.com/XingzhiDai/p/5325112.html

http://blog.csdn.net/mazhaojuan/article/details/21403717

https://jingyan.baidu.com/article/11c17a2c290124f446e39d0b.html

https://www.cnblogs.com/sunseine/p/5869878.html

https://www.cnblogs.com/applerosa/p/7141684.html

http://xylong.iteye.com/blog/1937906

https://segmentfault.com/q/1010000005988167

https://www.zhihu.com/question/30687062

http://www.infoq.com/cn/articles/netty-million-level-push-service-design-points

博客连载教程

http://blog.csdn.net/u013252773/article/details/21046697

https://waylau.gitbooks.io/netty-4-user-guide/

https://github.com/waylau

keysoftware的关于netty的帖子

https://keyholesoftware.com/2015/03/16/netty-a-different-kind-of-websocket-server/

https://www.codeproject.com/Articles/1102401/Whirlpool-Microservices-Using-Netty-And-Kafka

netty的例子

https://www.cnblogs.com/davidwang456/p/5035554.html

Netty和Vue是两个不同的技术,Netty是一款高性能的网络通信框架,而Vue是一款流行的前端框架。它们之间并没有直接的部署关系。但是,我们可以通过将Vue打包成静态文件,然后将这些文件部署Netty服务器上来实现Netty和Vue的部署。 具体步骤如下: 1. 在本地使用Vue CLI创建一个Vue项目,并编写前端代码。 2. 使用Vue CLI将Vue项目打包成静态文件。 3. 将打包后的静态文件复制到Netty服务器的静态资源目录下。 4. 在Netty服务器上编写代码,实现对静态资源的访问和处理。 5. 启动Netty服务器,访问静态资源的URL,即可看到Vue前端页面。 下面是一个简单的示例代码,用于在Netty服务器上实现对静态资源的访问和处理: ```java public class StaticResourceHandler extends SimpleChannelInboundHandler<FullHttpRequest> { private final String staticResourcePath; public StaticResourceHandler(String staticResourcePath) { this.staticResourcePath = staticResourcePath; } @Override protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { if (!request.decoderResult().isSuccess()) { sendError(ctx, HttpResponseStatus.BAD_REQUEST); return; } if (request.method() != HttpMethod.GET) { sendError(ctx, HttpResponseStatus.METHOD_NOT_ALLOWED); return; } String uri = request.uri(); String path = sanitizeUri(uri); if (path == null) { sendError(ctx, HttpResponseStatus.FORBIDDEN); return; } File file = new File(staticResourcePath + File.separator + path); if (file.isHidden() || !file.exists()) { sendError(ctx, HttpResponseStatus.NOT_FOUND); return; } if (!file.isFile()) { sendError(ctx, HttpResponseStatus.FORBIDDEN); return; } RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r"); long fileLength = randomAccessFile.length(); HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); HttpUtil.setContentLength(response, fileLength); setContentTypeHeader(response, file); setDateAndCacheHeaders(response, file); if (HttpUtil.isKeepAlive(request)) { response.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE); } ctx.write(response); ChannelFuture sendFileFuture; ChannelFuture lastContentFuture; if (ctx.pipeline().get(SslHandler.class) == null) { sendFileFuture = ctx.write(new DefaultFileRegion(randomAccessFile.getChannel(), 0, fileLength), ctx.newProgressivePromise()); lastContentFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT); } else { sendFileFuture = ctx.writeAndFlush(new HttpChunkedInput(new ChunkedFile(randomAccessFile, 0, fileLength, 8192)), ctx.newProgressivePromise()); lastContentFuture = sendFileFuture; sendFileFuture.addListener(new ChannelProgressiveFutureListener() { @Override public void operationProgressed(ChannelProgressiveFuture future, long progress, long total) { if (total < 0) { System.err.println("Transfer progress: " + progress); } else { System.err.println("Transfer progress: " + progress + " / " + total); } } @Override public void operationComplete(ChannelProgressiveFuture future) { System.err.println("Transfer complete."); } }); } sendFileFuture.addListener(ChannelFutureListener.CLOSE); } private static final Pattern INSECURE_URI = Pattern.compile(".*[<>&\"].*"); private String sanitizeUri(String uri) { try { uri = URLDecoder.decode(uri, "UTF-8"); } catch (UnsupportedEncodingException e) { try { uri = URLDecoder.decode(uri, "ISO-8859-1"); } catch (UnsupportedEncodingException e1) { throw new Error(); } } if (!uri.startsWith(staticResourcePath)) { return null; } if (!uri.startsWith("/")) { return null; } uri = uri.replace('/', File.separatorChar); if (uri.contains(File.separator + '.') || uri.contains('.' + File.separator) || uri.startsWith(".") || uri.endsWith(".") || INSECURE_URI.matcher(uri).matches()) { return null; } return uri; } private static void sendError(ChannelHandlerContext ctx, HttpResponseStatus status) { FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status, Unpooled.copiedBuffer("Failure: " + status.toString() + "\r\n", CharsetUtil.UTF_8)); response.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8"); ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } private static void setContentTypeHeader(HttpResponse response, File file) { MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap(); response.headers().set(HttpHeaderNames.CONTENT_TYPE, mimeTypesMap.getContentType(file.getPath())); } private static void setDateAndCacheHeaders(HttpResponse response, File fileToCache) { SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US); dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE)); Calendar time = new GregorianCalendar(); response.headers().set(HttpHeaderNames.DATE, dateFormatter.format(time.getTime())); time.add(Calendar.SECOND, HTTP_CACHE_SECONDS); response.headers().set(HttpHeaderNames.EXPIRES, dateFormatter.format(time.getTime())); response.headers().set(HttpHeaderNames.CACHE_CONTROL, "private, max-age=" + HTTP_CACHE_SECONDS); response.headers().set(HttpHeaderNames.LAST_MODIFIED, dateFormatter.format(new Date(fileToCache.lastModified()))); } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值