请求信息转换

  异步发送表单数据到JavaBean,并响应JSON文本返回

操作步骤:
(1)加入Jackson2或fastjson框架包,springmvc默认支持Jackon2,不需要做任何操作,而fastjson需要重新配置HttpMessageConverter。
(2)使用@RequestBody接收数据和@ResponseBody返回数据,
这两个动作完全是透明的。

使用jackson转换json数据

代码示例:

创建动态web项目,配置web.xml文件:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  3. <display-name>Jackson处理json</display-name>
  4. <welcome-file-list>
  5. <welcome-file>index.html</welcome-file>
  6. <welcome-file>index.htm</welcome-file>
  7. <welcome-file>index.jsp</welcome-file>
  8. <welcome-file>default.html</welcome-file>
  9. <welcome-file>default.htm</welcome-file>
  10. <welcome-file>default.jsp</welcome-file>
  11. </welcome-file-list>
  12. <!-- 定义Springmvc的前端控制器 -->
  13. <servlet>
  14. <servlet-name>springmvc</servlet-name>
  15. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  16. <!-- 指定解析文件 -->
  17. <init-param>
  18. <param-name>contextConfigLocation</param-name>
  19. <param-value>/WEB-INF/springmvc-config.xml</param-value>
  20. </init-param>
  21. <!-- 指定一开始就加载 -->
  22. <load-on-startup>1</load-on-startup>
  23. </servlet>
  24.  
  25. <!-- 让spring mvc 的前端控制器拦截所有的请求 -->
  26. <servlet-mapping>
  27. <servlet-name>springmvc</servlet-name>
  28. <url-pattern>*.jspx</url-pattern>
  29. </servlet-mapping>
  30. </web-app>

配置springmvc-config.xml文件:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:mvc="http://www.springframework.org/schema/mvc"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
  8. http://www.springframework.org/schema/context
  9. http://www.springframework.org/schema/context/spring-context-4.2.xsd
  10. http://www.springframework.org/schema/mvc
  11. http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
  12.  
  13. <!-- 自动扫描该包,SpringMVC会将包下用了@controller注解的类注册为Spring的controller -->
  14. <context:component-scan base-package="org.fkjava.action"/>
  15.  
  16. <mvc:annotation-driven/>
  17.  
  18. <!-- 视图解析器 -->
  19. <bean id="viewResolver"
  20. class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  21. <!-- 前缀 -->
  22. <property name="prefix">
  23. <value>/WEB-INF/jsp/</value>
  24. </property>
  25. <!-- 后缀 -->
  26. <property name="suffix">
  27. <value>.jsp</value>
  28. </property>
  29. </bean>
  30. </beans>

index.jsp页面

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>登录页面</title>
  8. </head>
  9. <body>
  10.  
  11. <a href="test1.jspx">测试RequestBody</a>
  12. <br><br>
  13. <a href="test2.jspx">测试ResponseBody</a>
  14. <br><br>
  15. <a href="test3.jspx">集合数据做成json返回</a>
  16.  
  17. </body>
  18. </html>

TestAction.java类

  1. package org.fkjava.action;
  2. import java.io.IOException;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import javax.servlet.http.HttpServletResponse;
  6. import org.codehaus.jackson.JsonGenerationException;
  7. import org.codehaus.jackson.map.JsonMappingException;
  8. import org.codehaus.jackson.map.ObjectMapper;
  9. import org.fkjava.domain.Book;
  10. import org.springframework.stereotype.Controller;
  11. import org.springframework.web.bind.annotation.RequestBody;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.ResponseBody;
  14.  
  15. @Controller//声明该类为控制器
  16. public class TestJson {
  17.  
  18. @RequestMapping("/test1.jspx")//映射index.jspx的请求
  19. public String test1(){
  20. //返回/WEB-INF/jsp/test1.jsp页面,这里在springmvc-config.xml配置了前缀和后缀
  21. return "test1";
  22. }
  23.  
  24. @RequestMapping("/test2.jspx")
  25. public String test2(){
  26. return "test2";
  27. }
  28.  
  29. @RequestMapping("/json/testRequestBody.jspx")//映射对应的请求路径
  30. public void testRequestBody(
  31. @RequestBody Book book,
  32. HttpServletResponse response) throws Exception{
  33. //用@RequestBody接收数据,得到Book对象
  34. //向book里添加数据
  35. book.setAuthor("张山");
  36. //Jackson开源类包操作json的类
  37. ObjectMapper mapper = new ObjectMapper();
  38. //将对象转成json字符串
  39. String json = mapper.writeValueAsString(book);
  40. //设置字符编码,输出到json客户端
  41. response.setContentType("text/html;charset=UTF-8");
  42. response.getWriter().print(json);
  43. }
  44.  
  45. /**(重点)
  46. * @ResponseBody会将集合数据转换json格式返回客户端
  47. * @return
  48. */
  49. @ResponseBody //使用@RequestBody接收数据和@ResponseBody返回数据
  50. @RequestMapping("/json/testResponseBody.jspx")
  51. public Object testResponseBody(
  52. @RequestBody Book book){
  53. book.setAuthor("李四");
  54. return book;
  55. }
  56.  
  57. @ResponseBody
  58. @RequestMapping("/json/testArray.jspx")
  59. public Object testArray(){
  60. //模拟数据库查询返回多个book对象
  61. List<Book> books = new ArrayList<>();
  62. books.add(new Book(1,"轻量级Java","李刚"));
  63. books.add(new Book(2,"疯狂讲义","李刚"));
  64. books.add(new Book(3,"Spring","肖"));
  65. return books;
  66. }
  67.  
  68. }

test1.jsp页面

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>测试接收JSON格式的数据</title>
  8. <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
  9. <script type="text/javascript" src="js/json2.js"></script>
  10. <script type="text/javascript">
  11. $(document).ready(function(){//页面一加载就会加载testRequestBody()方法
  12. testRequestBody();
  13. });
  14.  
  15. function testRequestBody(){
  16. $.ajax("${pageContext.request.contextPath}/json/testRequestBody.jspx",//发送请求
  17. {
  18. dataType : "json",//预期服务器返回的数据类型
  19. type : "post",//请求方式
  20. contentType : "application/json", //发送信息至服务器时的内容编码类型
  21. //发送到服务器的数据
  22. data:JSON.stringify({id : 1, name : "Spring MVC企业应用实战"}),
  23. async : true ,//默认设置下,所有请求均为异步请求,如果设置为false,则发送同步请求
  24. //请求成功后回调函数
  25. success : function(data){
  26. $("#id").html(data.id);
  27. $("#name").html(data.name);
  28. $("#author").html(data.author);
  29. },
  30. //请求出错时调用函数
  31. error : function(){
  32. alert("数据发送失败");
  33. }
  34. });
  35. }
  36. </script>
  37. </head>
  38. <body>
  39. 编号:<span id="id"></span><br>
  40. 书名:<span id="name"></span><br>
  41. 作者:<span id="author"></span><br></br>
  42. </body>
  43. </html>

test2.jsp页面

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>测试接收JSON格式的数据</title>
  8. <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
  9. <script type="text/javascript" src="js/json2.js"></script>
  10. <script type="text/javascript">
  11. $(document).ready(function(){//页面一加载就会加载testRequestBody()方法
  12. testRequestBody();
  13. });
  14.  
  15. function testRequestBody(){
  16. $.ajax("${pageContext.request.contextPath}/json/testResponseBody.jspx",//发送请求
  17. {
  18. dataType : "json",//预期服务器返回的数据类型
  19. type : "post",//请求方式
  20. contentType : "application/json", //发送信息至服务器时的内容编码类型
  21. async : true ,//默认设置下,所有请求均为异步请求,如果设置为false,则发送同步请求
  22. //请求成功后回调函数
  23. success : function(data){
  24. $("#id").html(data.id);
  25. $("#name").html(data.name);
  26. $("#author").html(data.author);
  27. },
  28. //请求出错时调用函数
  29. error : function(){
  30. alert("数据发送失败");
  31. }
  32. });
  33. }
  34. </script>
  35. </head>
  36. <body>
  37. 编号:<span id="id"></span><br>
  38. 书名:<span id="name"></span><br>
  39. 作者:<span id="author"></span><br></br>
  40. </body>
  41. </html>

test3.jsp页面

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>测试接收JSON格式的数据</title>
  8. <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
  9. <script type="text/javascript" src="js/json2.js"></script>
  10. <script type="text/javascript">
  11. $(document).ready(function(){//页面一加载就会加载testRequestBody()方法
  12. testRequestBody();
  13. });
  14.  
  15. function testRequestBody(){
  16. $.ajax("${pageContext.request.contextPath}/json/testArray.jspx",//发送请求
  17. {
  18. dataType : "json",//预期服务器返回的数据类型
  19. type : "post",//请求方式
  20. contentType : "application/json", //发送信息至服务器时的内容编码类型
  21. //发送到服务器的数据
  22. data:JSON.stringify({id : 1, name : "Spring MVC企业应用实战"}),
  23. async : true ,//默认设置下,所有请求均为异步请求,如果设置为false,则发送同步请求
  24. //请求成功后回调函数
  25. success : function(data){
  26. $.each(data,function(){
  27. var tr = $("<tr align='center'/>");
  28. $("<td/>").html(this.id).appendTo(tr);
  29. $("<td/>").html(this.name).appendTo(tr);
  30. $("<td/>").html(this.author).appendTo(tr);
  31. $("#booktable").append(tr);
  32. })
  33. },
  34. //请求出错时调用函数
  35. error : function(){
  36. alert("数据发送失败");
  37. }
  38. });
  39. }
  40. </script>
  41. </head>
  42. <body>
  43. <table id="booktable" border="1" style="border-collapse: collapse;">
  44. <tr align="center">
  45. <th>编号</th>
  46. <th>书名</th>
  47. <th>作者</th>
  48. </tr>
  49. </table>
  50. </body>
  51. </html>

domain

  1. package org.fkjava.domain;
  2.  
  3. public class Book {
  4.  
  5. private Integer id;
  6. private String name;
  7. private String author;
  8. public Book() {
  9. super();
  10. // TODO Auto-generated constructor stub
  11. }
  12. public Book(Integer id, String name, String author) {
  13. super();
  14. this.id = id;
  15. this.name = name;
  16. this.author = author;
  17. }
  18. public Integer getId() {
  19. return id;
  20. }
  21. public void setId(Integer id) {
  22. this.id = id;
  23. }
  24. public String getName() {
  25. return name;
  26. }
  27. public void setName(String name) {
  28. this.name = name;
  29. }
  30. public String getAuthor() {
  31. return author;
  32. }
  33. public void setAuthor(String author) {
  34. this.author = author;
  35. }
  36. @Override
  37. public String toString() {
  38. return "Book [id=" + id + ", name=" + name + ", author=" + author + "]";
  39. }
  40.  
  41. }

使用fastJson转换json数据

1、导包

2、配置web.xml文件

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  3. <display-name>fastjson操作json</display-name>
  4. <welcome-file-list>
  5. <welcome-file>index.html</welcome-file>
  6. <welcome-file>index.htm</welcome-file>
  7. <welcome-file>index.jsp</welcome-file>
  8. <welcome-file>default.html</welcome-file>
  9. <welcome-file>default.htm</welcome-file>
  10. <welcome-file>default.jsp</welcome-file>
  11. </welcome-file-list>
  12.  
  13. <!-- 定义springmvc的前端控制器 -->
  14. <servlet>
  15. <servlet-name>springmvc</servlet-name>
  16. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  17. <!-- 指定解析配置文件 -->
  18. <init-param>
  19. <param-name>contextConfigLocation</param-name>
  20. <param-value>/WEB-INF/springmvc-config.xml</param-value>
  21. </init-param>
  22. <!-- 设置一开始就加载 -->
  23. <load-on-startup>1</load-on-startup>
  24. </servlet>
  25.  
  26. <servlet-mapping>
  27. <servlet-name>springmvc</servlet-name>
  28. <url-pattern>*.jspx</url-pattern>
  29. </servlet-mapping>
  30.  
  31. </web-app>

2、配置springmvc-config.xml文件

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:mvc="http://www.springframework.org/schema/mvc"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xsi:schemaLocation="
  7. http://www.springframework.org/schema/beans
  8. http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
  9. http://www.springframework.org/schema/mvc
  10. http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
  11. http://www.springframework.org/schema/context
  12. http://www.springframework.org/schema/context/spring-context-4.2.xsd">
  13.  
  14. <!-- spring可以自动去扫描base-pack下面的包或者子包下面的java文件,
  15. 如果扫描到有Spring的相关注解的类,则把这些类注册为Spring的bean -->
  16. <context:component-scan base-package="org.fkjava.action"/>
  17.  
  18. <mvc:annotation-driven>
  19. <!-- 设置不使用默认的消息转换器 -->
  20. <mvc:message-converters register-defaults="false">
  21. <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
  22. <bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter"/>
  23. <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
  24. <bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter"/>
  25. <!-- 配置fastjson中实现HttpMessageConverter接口的转换器
  26. FastJsonHttpMessageConverter是fastjson中实现了HttpMessageConverter接口的类-->
  27. <bean id="fastJsonHttpMessageConverter"
  28. class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
  29. <!-- 加入支持的媒体类型:返回contentType -->
  30. <property name="supportedMediaTypes">
  31. <list>
  32. <!-- 这里顺序不能反,一定先写text/html,不然ie下会出现下载提示 -->
  33. <value>text/html;charset=UTF-8</value>
  34. <value>application/json;charset=UTF-8</value>
  35. </list>
  36. </property>
  37. </bean>
  38. </mvc:message-converters>
  39. </mvc:annotation-driven>
  40.  
  41. <mvc:default-servlet-handler/>
  42.  
  43. <!-- 视图解析器 -->
  44. <bean id="viewResolver"
  45. class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  46. <!-- 前缀 -->
  47. <property name="prefix">
  48. <value>/WEB-INF/jsp/</value>
  49. </property>
  50. <!-- 后缀 -->
  51. <property name="suffix">
  52. <value>.jsp</value>
  53. </property>
  54. </bean>
  55.  
  56. </beans>

index.jsp

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>登录页面</title>
  8. </head>
  9. <body>
  10.  
  11. <a href="test1.jspx">测试RequestBody</a>
  12. <br><br>
  13. <a href="test2.jspx">测试ResponseBody</a>
  14. <br><br>
  15. <a href="test3.jspx">集合数据做成json返回</a>
  16.  
  17. </body>
  18. </html>

TestJson.java类

  1. @Controller
  2. public class TestJson {
  3.  
  4. @RequestMapping("/test1.jspx")
  5. public String test1(){
  6. return "test1";
  7. }
  8.  
  9. @RequestMapping("/test2.jspx")
  10. public String test2(){
  11. return "test2";
  12. }
  13.  
  14. @RequestMapping("/test3.jspx")
  15. public String test3(){
  16. return "test3";
  17. }
  18.  
  19. @RequestMapping(value="/json/testRequestBody.jspx")
  20. public void setJson(@RequestBody Book book,
  21. HttpServletResponse response) throws Exception{
  22. book.setAuthor("肖老师");
  23. response.setContentType("text/html;charset=UTF-8");
  24. response.getWriter().print(JSONObject.toJSONString(book));
  25. }
  26.  
  27. //@esponseBody会将数据转换json格式返回客户端
  28. @ResponseBody
  29. @RequestMapping("/json/testResponseBody.jspx")
  30. public Object setJson2(
  31. @RequestBody Book book,
  32. HttpServletResponse response) throws Exception{
  33. book.setAuthor("张");
  34. return book;
  35. }
  36.  
  37. // @ResponseBody会将数据转换json格式返回客户端
  38. @ResponseBody
  39. @RequestMapping(value="/json/testArray.jspx")
  40. public Object testArray() throws Exception {
  41. List<Book> list = new ArrayList<Book>();
  42. list.add(new Book(1,"Spring MVC企业应用实战","肖文吉"));
  43. list.add(new Book(2,"轻量级JavaEE企业应用实战","李刚"));
  44. return list;
  45. }
  46. }

test1.jsp页面和test2.jsp,和test3.jsp页面以及domain同上

springmvc(二)的更多相关文章

  1. SpringMVC(二)——流程控制

    SpringMVC主要就是用来做流程控制的,这篇博客总结一下如何在流程控制添加Interceptor(拦截器),如何将进行流程Mapping映射解析,如何编写Controller(控制器). 一,首先 ...

  2. springmvc(二) ssm框架整合的各种配置

    ssm:springmvc.spring.mybatis这三个框架的整合,有耐心一步步走. --WH 一.SSM框架整合 1.1.整合思路 从底层整合起,也就是先整合mybatis与spring,然后 ...

  3. SpringMVC(二) SpringMVC Hello World

    准备条件: STS(集成了Spring相关工具的Eclipse) Spring软件包 spring-framework-4.3.3.RELEASE-dist.zip. 步骤: 加入jar包. Ecli ...

  4. 浅谈SpringMVC(二)

    一.SpringMVC的拦截器 1.写类implements HandlerInterceptor public class MyMvcInterceptor implements HandlerIn ...

  5. SpringMVC(二):RequestMapping修饰类、指定请求方式、请求参数或请求头、支持Ant路径

    @RequestMapping用来映射请求:RequestMapping可以修饰方法外,还可以修饰类 1)SpringMVC使用@RequestMapping注解为控制指定可以处理哪些URL请求: 2 ...

  6. SpringMVC(二六) SpringMVC配置文件中使用mvc:view-controller标签

    在springmvc中使用mvc:view-controller标签直接将访问url和视图进行映射,而无需要通过控制器. 参考springmvc.xml内容: <?xml version=&qu ...

  7. SpringMVC(二五) JSTL View

    项目中使用JSTL,SpringMVC会把视图由InternalView转换为JstlView. 若使用Jstl的fmt标签,需要在SpringMVC的配置文件中配置国际化资源文件. 实现过程: 1. ...

  8. SpringMVC(二四) 视图解析流程

    目标方法无论返回的是string.ModelAndView.View,最终都被解析成modelAndView 关键的实现代码是在springmvc.xml配置文件中定义解析器. 参考代码如下: < ...

  9. springMVC(二): @RequestBody @ResponseBody 注解实现分析

    一.继承结构 @RequestBody.@ResponseBody的处理器:RequestResponseBodyMethodProcessor @ModelAttribute处理器: ModelAt ...

  10. SpringMVC(二)高级

    高级参数绑定 1.1. 绑定数组 1.1.1. 需求 在商品列表页面选中多个商品,然后删除. 1.1.2. 需求分析 功能要求商品列表页面中的每个商品前有一个checkbok,选中多个商品后点击删除按 ...

随机推荐

  1. Leetcode之二分法专题-367. 有效的完全平方数(Valid Perfect Square)

    Leetcode之二分法专题-367. 有效的完全平方数(Valid Perfect Square) 给定一个正整数 num,编写一个函数,如果 num 是一个完全平方数,则返回 True,否则返回 ...

  2. mysql8.0版本下命令行mysqld –skip-grant-tables 失效,无法登陆的问题

    1.管理员权限登陆cmd,不会使用管理员登陆的请搜索cmd,搜索结果右键. 2.命令行输入:net stop mysql;然后提示.服务停止中 --> 服务已停止,如出现其他错误请百度. 这只是 ...

  3. CodeForces 715B Complete The Graph 特殊的dijkstra

    Complete The Graph 题解: 比较特殊的dij的题目. dis[x][y] 代表的是用了x条特殊边, y点的距离是多少. 然后我们通过dij更新dis数组. 然后在跑的时候,把特殊边都 ...

  4. asp.net core系列 72 Exceptionless使用介绍

    一.Exceptionless介绍 Exceptionless专注于.net平台提供实时错误和日志报告.主要包括:错误通知.智能分组异常.详细错误报告堆栈跟踪.支持离线.UI查看重要错误和确定优先级. ...

  5. java基础面试(二)

    最近有搜了几个面试题,大家一起来探讨一下. 1.Oracle 的分页 --分页查询一 select * from (select a1.*,rownum rn from (select * from ...

  6. 一起来读Netty In Action之传输(三)

    当我们的应用程序需要接受比预期多很多的并发连接的时候,我们需要从阻塞传输切换到非阻塞传输上去,如果是我们的网络编程是基于jdk提供的API进行开发地的话,这种传输模式的切换几乎要我们重构整个网络传输相 ...

  7. 【入门】广电行业DNS、DHCP解决方案详解(三)——DNS部署架构及案

    [入门]广电行业DNS.DHCP解决方案详解(三)——DNS部署架构及案 DNS系统部署架构 宽带业务DNS架构 互动业务DNS架构 案例介绍 案例一 案例二 本篇我们将先介绍DNS系统部署架构体系, ...

  8. 关于Java网络编程

    一,网络编程中两个主要的问题 一个是如何准确的定位网络上一台或多台主机,另一个就是找到主机后如何可靠高效的进行数据传输. 在TCP/IP协议中IP层主要负责网络主机的定位,数据传输的路由,由IP地址可 ...

  9. 通过Service访问应用 (2)

    目录 通过NodePort Service在外部访问集群应用 通过LoadBalancer Service在外部访问集群应用 Microsoft SQL Server数据库部署 为了便于理解和学习,请 ...

  10. 警告:Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!

    执行Maven Install打包的时候,提示以下警告信息: [WARNING] Using platform encoding (GBK actually) to copy filtered res ...