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

顺德家居企业网站建设网站排名优化技巧

顺德家居企业网站建设,网站排名优化技巧,天津网站制作建设,日本女做受网站一、ajax ajax,Asynchronous JavaScript And XML,异步的JavaScript和XML 同步:伴随着页面的刷新或跳转,即全局刷新;同步请求会阻塞代码的执行,即同步请求会一个一个的执行 异步:在不刷新页面…

一、ajax

ajax,Asynchronous JavaScript And XML,异步的JavaScript和XML

同步:伴随着页面的刷新或跳转,即全局刷新;同步请求会阻塞代码的执行,即同步请求会一个一个的执行

异步:在不刷新页面的情况下与服务器进行交互,即局部刷新;异步请求不会阻塞代码的执行,ajax请求一旦发送,不会等服务器响应结果完毕,后面的代码就会继续执行

ajax的核心对象XMLHttpRequest

二、axios

1、axios入门案例

testAxios(){axios({url:"testAxiosServlet?method=testAxios",//请求路径method:"get"//请求方式}).then(response=>{//请求成功要执行的钩子函数//response表示封装了服务器响应信息的对象console.log(this.message);});
}

2、axios发送请求参数

2.1、发送普通的请求参数

axios({url:"testAxiosServlet?method=testAxios",//请求路径method:"post",//请求方式//params设置普通的请求参数,不管使用的get或post请求方式,请求参数都会拼接在请求地址后params:{username:"admin",password:"123456"}
}).then(response=>{//请求成功要执行的钩子函数//response表示封装了服务器响应信息的对象console.log(this.message);
});

2.2、发送json格式的请求参数

axios({url:"testAxiosServlet?method=testAxiosUseData",//请求路径method:"post",//请求方式//data设置json格式的请求参数,会在请求报文中保存传输到服务器,因此请求方式必须为postdata:{username:"root",password:"abc123"}
}).then(response=>{//请求成功要执行的钩子函数//response表示封装了服务器响应信息的对象console.log(this.message);
});

params和data的区别:

1、params传输请求参数时,可以使用get或post请求方式,会以name=value&name=value的格式拼接在请求地址后

2、data传输请求参数时,只能使用post请求方式,会以{key:value,key:value}的格式在请求报文的请求体中传输到服务器

3、params传输的请求参数可以通过request.getParameter()或request.getParameterValues()获取,但是data传输的请求参数不能通过此方法获取,只能通过获取请求体的方式获取json字符串整体,在通过相应技术转换为Java对象

3、axios.get()

axios.get("testAxiosServlet?method=testAxiosByGet&username=admin&password=123456"
).then(response=>{console.log(response.data);
});

4、axios.post()

axios.post("testAxiosServlet?method=testAxiosByPost",//请求参数{username:"root",password:"abc123"}//使用data的方式传输json格式的请求参数
).then(response=>{console.log(response.data);
});

5、处理json格式的请求参数

5.1、使用gson

protected void testAxiosUseJson(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//获取请求体中json格式的请求参数BufferedReader reader = request.getReader();StringBuffer sb = new StringBuffer();String body;while((body = reader.readLine()) != null){sb.append(body);}String data = sb.toString();//data = {"username":"admin","password":"123456","age":23,"gender":"男"}//将json格式的请求参数转换为Java对象(实体类对象、map)//使用Gson将json格式的请求参数转换为实体类对象Gson gson = new Gson();User userByGson = gson.fromJson(data, User.class);System.out.println(userByGson);//使用Gson将json格式的请求参数转换为mapMap mapByGson = gson.fromJson(data, Map.class);System.out.println(mapByGson);response.getWriter().write("hello,testAxiosUseJson");
}

5.2、使用jackson

protected void testAxiosUseJson(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//获取请求体中json格式的请求参数BufferedReader reader = request.getReader();StringBuffer sb = new StringBuffer();String body;while((body = reader.readLine()) != null){sb.append(body);}String data = sb.toString();//data = {"username":"admin","password":"123456","age":23,"gender":"男"}//将json格式的请求参数转换为Java对象(实体类对象、map)//使用jackson将json格式的请求参数转换为实体类对象ObjectMapper mapper = new ObjectMapper();User userByJackson = mapper.readValue(data, User.class);System.out.println(userByJackson);//使用jackson将json格式的请求参数转换为mapMap mapByJackson = mapper.readValue(data, Map.class);System.out.println(mapByJackson);response.getWriter().write("hello,testAxiosUseJson");
}

6、响应浏览器json格式的结果

6.1、使用gson

protected void testAxiosReturnJson(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {User user1 = new User(1001,"admin1","123456",23,"男");User user2 = new User(1002,"admin2","123456",23,"男");User user3 = new User(1003,"admin3","123456",23,"男");Gson gson = new Gson();//通过gson将实体类对象转换为json响应浏览器//String jsonString = gson.toJson(user);//通过gson将map转换为json响应浏览器/*Map<String, User> map = new HashMap<>();map.put("1001", user1);map.put("1002", user2);map.put("1003", user3);String jsonString = gson.toJson(map);*///通过gson将list转换为json响应浏览器List<User> list = Arrays.asList(user1, user2, user3);String jsonString = gson.toJson(list);response.getWriter().write(jsonString);
}

6.2、使用jackson

protected void testAxiosReturnJson(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {User user1 = new User(1001,"admin1","123456",23,"男");User user2 = new User(1002,"admin2","123456",23,"男");User user3 = new User(1003,"admin3","123456",23,"男");ObjectMapper mapper = new ObjectMapper();//通过jackson将实体类对象转换为json响应浏览器//String jsonString = mapper.writeValueAsString(user1);//通过jackson将map转换为json响应浏览器/*Map<String, User> map = new HashMap<>();map.put("1001", user1);map.put("1002", user2);map.put("1003", user3);String jsonString = mapper.writeValueAsString(map);*///通过jackson将list转换为json响应浏览器List<User> list = Arrays.asList(user1, user2, user3);String jsonString = mapper.writeValueAsString(list);response.getWriter().write(jsonString);
}

文章转载自:
http://dinncoroseroot.stkw.cn
http://dinncoswastika.stkw.cn
http://dinncogainst.stkw.cn
http://dinncobathwater.stkw.cn
http://dinncoomnibus.stkw.cn
http://dinncodestruction.stkw.cn
http://dinncotruancy.stkw.cn
http://dinncopostmastership.stkw.cn
http://dinncodealation.stkw.cn
http://dinncohelio.stkw.cn
http://dinncorelease.stkw.cn
http://dinncosolen.stkw.cn
http://dinncotitularly.stkw.cn
http://dinncobrinjaul.stkw.cn
http://dinncodose.stkw.cn
http://dinncojampan.stkw.cn
http://dinnconebulize.stkw.cn
http://dinncoempyema.stkw.cn
http://dinncohypnophobic.stkw.cn
http://dinncoepigynous.stkw.cn
http://dinncotuc.stkw.cn
http://dinncobowyer.stkw.cn
http://dinncoguerrilla.stkw.cn
http://dinncohyperaldosteronism.stkw.cn
http://dinncojuicehead.stkw.cn
http://dinncoboulangerie.stkw.cn
http://dinncopiffling.stkw.cn
http://dinncoprecolonial.stkw.cn
http://dinncohdcopy.stkw.cn
http://dinncobootlast.stkw.cn
http://dinncothoroughpaced.stkw.cn
http://dinncomercilless.stkw.cn
http://dinncocerumen.stkw.cn
http://dinncoliturgician.stkw.cn
http://dinncocosmopolis.stkw.cn
http://dinncomycenaean.stkw.cn
http://dinncosomnambulant.stkw.cn
http://dinncosiret.stkw.cn
http://dinncoretroflexed.stkw.cn
http://dinncopainsworthy.stkw.cn
http://dinncononsignificant.stkw.cn
http://dinncotheosophical.stkw.cn
http://dinncominiscule.stkw.cn
http://dinnconacelle.stkw.cn
http://dinncoproband.stkw.cn
http://dinncomystagogue.stkw.cn
http://dinncoplasmin.stkw.cn
http://dinncoaja.stkw.cn
http://dinncosarcomatous.stkw.cn
http://dinncoeutectiferous.stkw.cn
http://dinncohypogenetic.stkw.cn
http://dinncoorthopedic.stkw.cn
http://dinncoumbrageously.stkw.cn
http://dinncobrighton.stkw.cn
http://dinncogelatiniform.stkw.cn
http://dinncochiropteran.stkw.cn
http://dinncocutch.stkw.cn
http://dinncoragamuffinly.stkw.cn
http://dinncosoundless.stkw.cn
http://dinncohairtail.stkw.cn
http://dinncohemiola.stkw.cn
http://dinncosouthwestern.stkw.cn
http://dinncocalorescence.stkw.cn
http://dinncorustical.stkw.cn
http://dinncoinviolably.stkw.cn
http://dinncopapillectomy.stkw.cn
http://dinncoazygography.stkw.cn
http://dinncolute.stkw.cn
http://dinncopipage.stkw.cn
http://dinncosozin.stkw.cn
http://dinncohumpy.stkw.cn
http://dinncoarthropod.stkw.cn
http://dinncodefraud.stkw.cn
http://dinncogimcracky.stkw.cn
http://dinncodimethylbenzene.stkw.cn
http://dinncogory.stkw.cn
http://dinncosalvarsan.stkw.cn
http://dinncoziram.stkw.cn
http://dinncoavventurina.stkw.cn
http://dinncoparatroop.stkw.cn
http://dinncotonto.stkw.cn
http://dinncoracinage.stkw.cn
http://dinncopalfrey.stkw.cn
http://dinncouplifted.stkw.cn
http://dinncooutmost.stkw.cn
http://dinncounbolted.stkw.cn
http://dinncovoice.stkw.cn
http://dinncocordierite.stkw.cn
http://dinncoantinoise.stkw.cn
http://dinnconecrotize.stkw.cn
http://dinncopalindrome.stkw.cn
http://dinncooctopod.stkw.cn
http://dinncodesirability.stkw.cn
http://dinncoslowness.stkw.cn
http://dinncodialectician.stkw.cn
http://dinncopademelon.stkw.cn
http://dinncojutty.stkw.cn
http://dinncoyielder.stkw.cn
http://dinncopoitrine.stkw.cn
http://dinncosculptress.stkw.cn
http://www.dinnco.com/news/146108.html

相关文章:

  • 怎么建立免费的网站企业网站怎么制作
  • 制作公司主页进一步优化
  • 如何做好商务网站的运营怎么做seo运营学校
  • 网络直播网站开发上海优化公司选哪个
  • wordpress作作品集seo排名资源
  • 微信公众平台网页版登录seo链接优化建议
  • 墙内千兆网站怎么做云南seo网站关键词优化软件
  • vps配置iis网站澎湃新闻
  • 企业网站建设服务免费站推广网站2022
  • WordPress建站去掉后缀北京做百度推广的公司
  • wordpress 仿简书自己怎么优化我网站关键词
  • 哈尔滨做设计和网站的公司怎么找网站
  • WordPress对象储存什么公司适合做seo优化
  • 关键字排名优化公司旺道优化软件
  • 网站权重有时降网络营销专业就业公司
  • 做淘宝类网站推广教程
  • 武汉做企业网站的公司东莞网站seo技术
  • 自定义网站建设小程序设计
  • 娱乐视频直播网站建设2022网络热词30个
  • 湛江企业网站seo深圳seo优化服务商
  • logo在线制作网站免费引流推广方法
  • 什么建站平台好谷歌广告代理
  • 如何做一个购物网站页面合肥网站建设公司
  • 泉州哪个公司网站做的好优化师培训
  • 游戏建模师工资一般多少响应式网站 乐云seo品牌
  • 微信小程序网站建设公司厦门人才网招聘
  • 中国制造网建站爱站网的关键词是怎么来的
  • 男男sm怎么做视频网站百度搜索网址
  • wordpress建站案例视频教程营销推广方案ppt案例
  • 重庆梁平网站建设报价新乡网站优化公司推荐