springmvc.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:aop="http://www.springframework.org/schema/aop"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xmlns:mvc="http://www.springframework.org/schema/mvc"
  7. xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
  8. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  9. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
  10. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
  11.  
  12. <!-- 扫描 有注解的包 -->
  13. <context:component-scan base-package="handler"></context:component-scan>
  14.  
  15. <!--配置视图解析器(InternalResourceViewResolver) -->
  16. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  17. <property name="prefix" value="/views/"></property>
  18. <property name="suffix" value=".jsp"></property>
  19. </bean>
  20.  
  21. <!--view-name会被视图解析器 加上前缀、后缀 -->
  22. <mvc:view-controller path="handler/testMvcViewController" view-name="success"/>
  23.  
  24. <!-- 该注解 会让 springmvc: 接收一个请求,并且该请求 没有对应的@requestmapping时,将该请求 交给服务器默认的servlet去处理(直接访问) -->
  25. <mvc:default-servlet-handler></mvc:default-servlet-handler>
  26.  
  27. <!-- 1将 自定义转换器 纳入SpringIOC容器 -->
  28. <bean id="myConverter" class="converter.MyConverter"></bean>
  29.  
  30. <!-- 2将myConverter再纳入 SpringMVC提供的转换器Bean
  31. <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
  32. <property name="converters">
  33. <set>
  34. <ref bean="myConverter"/>
  35. </set>
  36. </property>
  37. </bean>
  38. -->
  39.  
  40. <!-- 3将conversionService注册到annotation-driven中 -->
  41. <!--此配置是SpringMVC的基础配置,很功能都需要通过该注解来协调 -->
  42. <mvc:annotation-driven conversion-service="conversionService"></mvc:annotation-driven>
  43.  
  44. <!-- 配置 数据格式化 注解 所依赖的bean FormattingConversionServiceFactoryBean:既可以实现格式化、又可以实现类型转换 -->
  45. <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
  46. <property name="converters">
  47. <set>
  48. <ref bean="myConverter"/>
  49. </set>
  50. </property>
  51. </bean>
  52.  
  53. </beans>

web.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  5. version="3.1">
  6.  
  7. <servlet>
  8. <servlet-name>springDispatcherServlet</servlet-name>
  9. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  10. <init-param>
  11. <param-name>contextConfigLocation</param-name>
  12. <param-value>classpath:springmvc.xml</param-value>
  13. </init-param>
  14. <load-on-startup>1</load-on-startup>
  15. </servlet>
  16. <servlet-mapping>
  17. <servlet-name>springDispatcherServlet</servlet-name>
  18. <url-pattern>/</url-pattern>
  19. </servlet-mapping>
  20.  
  21. <filter>
  22. <filter-name>HiddenHttpMethodFilter</filter-name>
  23. <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
  24. </filter>
  25. <filter-mapping>
  26. <filter-name>HiddenHttpMethodFilter</filter-name>
  27. <url-pattern>/*</url-pattern>
  28. </filter-mapping>
  29.  
  30. </web-app>

SpringMvcHandler

  1. package handler;
  2.  
  3. import java.util.Map;
  4.  
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import entity.Address;
  8. import entity.Student;
  9. import org.springframework.stereotype.Controller;
  10. import org.springframework.ui.Model;
  11. import org.springframework.ui.ModelMap;
  12. import org.springframework.validation.BindingResult;
  13. import org.springframework.validation.FieldError;
  14. import org.springframework.web.bind.annotation.CookieValue;
  15. import org.springframework.web.bind.annotation.ModelAttribute;
  16. import org.springframework.web.bind.annotation.PathVariable;
  17. import org.springframework.web.bind.annotation.RequestHeader;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RequestMethod;
  20. import org.springframework.web.bind.annotation.RequestParam;
  21. import org.springframework.web.bind.annotation.SessionAttributes;
  22. import org.springframework.web.servlet.ModelAndView;
  23.  
  24. //接口/类 注解 配置
  25. //@SessionAttributes(value="student4") //如果要在request中存放student4对象,则同时将该对象 放入session域中
  26. //@SessionAttributes(types= {Student.class,Address.class}) //如果要在request中存放Student类型的对象,则同时将该类型对象 放入session域中
  27. @Controller
  28. @RequestMapping(value = "handler") //映射
  29. public class SpringMVCHandler {
  30. @RequestMapping(value = "welcome", method = RequestMethod.POST, params = {"name=zs", "age!=23", "!height"})//映射
  31. public String welcome() {
  32. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  33. }
  34.  
  35. @RequestMapping(value = "welcome2", headers = {"Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Encoding=gzip, deflate"})
  36. public String welcome2() {
  37. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  38. }
  39.  
  40. @RequestMapping(value = "welcome3/**/test")
  41. public String welcome3() {
  42. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  43. }
  44.  
  45. @RequestMapping(value = "welcome4/a?c/test")
  46. public String welcome4() {
  47. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  48. }
  49.  
  50. @RequestMapping(value = "welcome5/{name}")
  51. public String welcome5(@PathVariable("name") String name) {
  52. System.out.println(name);
  53. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  54. }
  55.  
  56. @RequestMapping(value = "testRest/{id}", method = RequestMethod.POST)
  57. public String testPost(@PathVariable("id") Integer id) {
  58. System.out.println("post:增 " + id);
  59. //Service层实现 真正的增
  60. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  61. }
  62.  
  63. @RequestMapping(value = "testRest/{id}", method = RequestMethod.GET)
  64. public String testGet(@PathVariable("id") Integer id) {
  65. System.out.println("get:查 " + id);
  66. //Service层实现 真正的增
  67. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  68. }
  69.  
  70. @RequestMapping(value = "testRest/{id}", method = RequestMethod.DELETE)
  71. public String testDelete(@PathVariable("id") String id) {
  72. System.out.println("delete:删 " + id);
  73. //Service层实现 真正的增
  74. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  75. }
  76.  
  77. @RequestMapping(value = "testRest/{id}", method = RequestMethod.PUT)
  78. public String testPut(@PathVariable("id") Integer id) {
  79. System.out.println("put:改 " + id);
  80. //Service层实现 真正的增
  81. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  82. }
  83.  
  84. @RequestMapping(value = "testParam")
  85. public String testParam(@RequestParam("uname") String name, @RequestParam(value = "uage", required = false, defaultValue = "23") Integer age) {
  86. // String name = request.getParameter("uname");
  87.  
  88. System.out.println(name);
  89. System.out.println(age);
  90. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  91. }
  92.  
  93. @RequestMapping(value = "testRequestHeader")
  94. public String testRequestHeader(@RequestHeader("Accept-Language") String al) {
  95. System.out.println(al);
  96. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  97. }
  98.  
  99. @RequestMapping(value = "testCookieValue")
  100. public String testCookieValue(@CookieValue("JSESSIONID") String jsessionId) {
  101. System.out.println(jsessionId);
  102. return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
  103. }
  104.  
  105. @RequestMapping(value = "testObjectProperties")
  106. public String testObjectProperties(Student student) {//student属性 必须 和 form表单中的属性Name值一致(支持级联属性)
  107. /*
  108. String name = request.getParameter("name");
  109. int age= Integer.parseInt(request.getParameter("age")s) ;
  110. String haddrss = request.getParameter("homeaddress");
  111. String saddress = request.getParameter("schooladdress");
  112. Address address = new Address();
  113. address.setHomeAddress(haddrss);
  114. address.setSchoolAddress(saddress);
  115.  
  116. Student student = new Student();
  117. student.setName(name);
  118. student.setAddress(address);
  119. */
  120. System.out.println(student.getId() + "," + student.getName() + "," + student.getAddress().getHomeAddress() + "," + student.getAddress().getSchoolAddress());
  121. return "success";
  122. }
  123.  
  124. @RequestMapping(value = "testServletAPI")
  125. public String testServletAPI(HttpServletRequest request, HttpServletResponse response) {
  126. // request.getParameter("uname") ;
  127. System.out.println(request);
  128. return "success";//succes.jsp
  129. }
  130.  
  131. @RequestMapping(value = "testModelAndView")
  132. public ModelAndView testModelAndView() {//ModelAndView:既有数据,又有视图
  133. //ModelAndView:Model -M View-V
  134. ModelAndView mv = new ModelAndView("success");//view: views/success.jsp
  135.  
  136. Student student = new Student();
  137. student.setId(2);
  138. student.setName("zs");
  139.  
  140. mv.addObject("student", student);//相当于request.setAttribute("student", student);
  141. return mv;
  142. }
  143.  
  144. @RequestMapping(value = "testModelMap")
  145. public String testModelMap(ModelMap mm) {//success
  146.  
  147. Student student = new Student();
  148. student.setId(2);
  149. student.setName("zs");
  150.  
  151. mm.put("student2", student);//request域
  152. //forward: redirect:
  153. //
  154. return "redirect:/views/success.jsp";
  155. }
  156.  
  157. @RequestMapping(value = "testMap")
  158. public String testMap(Map<String, Object> m) {
  159.  
  160. Student student = new Student();
  161. student.setId(2);
  162. student.setName("zs");
  163. m.put("student3", student);//request域
  164.  
  165. return "success";
  166. }
  167.  
  168. @RequestMapping(value = "testModel")
  169. public String testModel(Model model) {
  170.  
  171. Student student = new Student();
  172. student.setId(2);
  173. student.setName("zs");
  174. model.addAttribute("student4", student);//request域
  175. return "success";
  176. }
  177.  
  178. @ModelAttribute//在任何一次请求前,都会先执行@ModelAttribute修饰的方法
  179. //@ModelAttribute 在请求 该类的各个方法前 均被执行的设计是基于一个思想:一个控制器 只做一个功能
  180. public void queryStudentById(Map<String, Object> map) {
  181. //StuentService stuService = new StudentServiceImpl();
  182. //Student student = stuService.queryStudentById(31);
  183. //模拟调用三层查询数据库的操作
  184. Student student = new Student();
  185. student.setId(31);
  186. student.setName("zs");
  187. student.setAge(23);
  188. // map.put("student", student) ;//约定:map的key 就是方法参数 类型的首字母小写
  189. map.put("stu", student);//约定:map的key 就是方法参数 类型的首字母小写
  190. }
  191.  
  192. //修改:Zs-ls
  193. @RequestMapping(value = "testModelAttribute")
  194. public String testModelAttribute(@ModelAttribute("stu") Student student) {
  195. student.setName(student.getName());//将名字修改为ls
  196. System.out.println(student.getId() + "," + student.getName() + "," + student.getAge());
  197. return "success";
  198. }
  199.  
  200. @RequestMapping(value = "testI18n")
  201. public String testI18n() {
  202. return "success";
  203. }
  204.  
  205. @RequestMapping(value = "testConverter")
  206. public String testConverter(@RequestParam("studentInfo") Student student) {// 前端:2-zs-23
  207.  
  208. System.out.println(student.getId() + "," + student.getName() + "," + student.getAge());
  209.  
  210. return "success";
  211. }
  212.  
  213. @RequestMapping(value = "testDateTimeFormat")//如果Student格式化出错,会将错误信息 传入result中
  214. public String testDateTimeFormat(Student student, BindingResult result) {
  215.  
  216. System.out.println(student.getId() + "," + student.getName() + "," + student.getBirthday());
  217.  
  218. if (result.getErrorCount() > 0) {
  219. for (FieldError error : result.getFieldErrors()) {
  220. System.out.println(error.getDefaultMessage());
  221. }
  222. }
  223. return "success";
  224. }
  225.  
  226. }

Myconvert

  1. package converter;
  2.  
  3. import entity.Student;
  4. import org.springframework.core.convert.converter.Converter;
  5.  
  6. public class MyConverter implements Converter<String, Student> {
  7.  
  8. @Override
  9. public Student convert(String source) {//source:2-zs-23
  10. String[] studentStrArr = source.split("-");
  11. Student student = new Student();
  12. student.setId(Integer.parseInt(studentStrArr[0]));
  13. student.setName(studentStrArr[1]);
  14. student.setAge(Integer.parseInt(studentStrArr[2]));
  15. return student;
  16. }
  17. }

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>Insert title here</title>
  8. </head>
  9. <body>
  10.  
  11. <!-- 如果web.xml中的配置是
  12. <servlet-mapping>
  13. <servlet-name>springDispatcherServlet</servlet-name>
  14. <url-pattern>.action</url-pattern>
  15. </servlet-mapping>
  16.  
  17. <a href="user/welcome.action">first springmvc - welcome</a> 交由springmvc处理 找 @RuestMapping映射
  18. <a href="user/welcome.action">first springmvc - welcome</a>交由springmvc处理 找 @RuestMapping映射
  19. <a href="xxx/welcome">first springmvc - welcome</a> 交由servlet处理 找url-parttern /@WebServlet()
  20. -->
  21. <a href="handler/welcome3/xyz/abcz/asb/test">33333333get - welcome</a>
  22. <br/>
  23. <a href="handler/welcome4/abc/test">4444444get - welcome</a>
  24. <br/>
  25. <a href="handler/welcome5/zs">555welcome</a>
  26.  
  27. <form action="handler/welcome" method="post">
  28. name:<input name="name" ><br/>
  29. age:<input name="age" >
  30. height:<input name="height" >
  31. <input type="submit" value="post">
  32. </form>
  33.  
  34. <br/>======<br/>
  35.  
  36. <form action="handler/testRest/1234" method="post">
  37. <input type="submit" value="增">
  38. </form>
  39.  
  40. <form action="handler/testRest/1234" method="post">
  41. <input type="hidden" name="_method" value="DELETE"/>
  42. <input type="submit" value="删">
  43. </form>
  44.  
  45. <form action="handler/testRest/1234" method="post">
  46. <input type="hidden" name="_method" value="PUT"/>
  47. <input type="submit" value="改">
  48. </form>
  49.  
  50. <form action="handler/testRest/1234" method="get">
  51. <input type="submit" value="查">
  52. </form>
  53. ------------<br/>
  54. <form action="handler/testParam" method="get">
  55. name:<input name="uname" type="text" />
  56. <input type="submit" value="查">
  57. </form>
  58. <br/>
  59. <a href="handler/testRequestHeader">testRequestHeader</a>
  60. <br/>
  61. <br/>
  62. <a href="handler/testCookieValue">testCookieValue</a><br/>
  63. <a href="handler/testServletAPI">testServletAPI</a>
  64. <br/>
  65. <form action="handler/testObjectProperties" method="post">
  66. id:<input name="id" type="text" />
  67. name:<input name="name" type="text" />
  68. 家庭地址:<input name="address.homeAddress" type="text" />
  69. 学校地址:<input name="address.schoolAddress" type="text" />
  70. <input type="submit" value="查">
  71. </form>
  72.  
  73. <br/>
  74. <a href="handler/testModelAndView">testModelAndView</a>
  75. <br/>
  76. <br/>
  77. <a href="handler/testModelMap">testModelMap</a>
  78. <br/>
  79. <br/>
  80. <a href="handler/testMap">testMap</a>
  81. <br/>
  82. <br/>
  83. <a href="handler/testModel">testModel</a>
  84. <br/>
  85. <br/>
  86. <a href="handler/testI18n">testI18n</a>
  87. <br/>
  88.  
  89. <form action="handler/testModelAttribute" method="post">
  90. 编号:<input name="id" type="hidden" value="31" />
  91. 姓名:<input name="name" type="text" />
  92. <input type="submit" value="修改">
  93. </form>
  94.  
  95. <br/>
  96. <a href="handler/testMvcViewController">testMvcViewController</a>
  97. <br/>
  98.  
  99. <form action="handler/testConverter" method="post">
  100. 学生信息:<input name="studentInfo" type="text" /><!-- 2-zs-23 -->
  101. <input type="submit" value="转换">
  102. </form>
  103.  
  104. <form action="handler/testDateTimeFormat" method="post">
  105. 编号:<input name="id" type="text" value="31" />
  106. 姓名:<input name="name" type="text" />
  107. 出生日期:<input name="birthday" type="text" />
  108. <input type="submit" value="修改">
  109. </form>
  110.  
  111. </body>
  112. </html>

success.jsp

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3.  
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  8. <title>Insert title here</title>
  9. </head>
  10. <body>
  11. welcome to spring mvc success<br/>
  12. ==== request:<br/>
  13. ${requestScope.student.id } -${requestScope.student.name } <br/>
  14. ${requestScope.student2.id } -${requestScope.student2.name } <br/>
  15. ${requestScope.student3.id } -${requestScope.student3.name } <br/>
  16. ${requestScope.student4.id } -${requestScope.student4.name } <br/>
  17.  
  18. ==== session:<br/>
  19. ${sessionScope.student.id } -${sessionScope.student.name } <br/>
  20. ${sessionScope.student2.id } -${sessionScope.student2.name } <br/>
  21. ${sessionScope.student3.id } -${sessionScope.student3.name } <br/>
  22. ${sessionScope.student4.id } -${sessionScope.student4.name } <br/>
  23. </body>
  24. </html>

Student

  1. package entity;
  2.  
  3. import org.springframework.format.annotation.DateTimeFormat;
  4.  
  5. public class Student {
  6. private int id;
  7. private String name;
  8. private Address address;
  9.  
  10. public String getBirthday() {
  11. return birthday;
  12. }
  13.  
  14. public void setBirthday(String birthday) {
  15. this.birthday = birthday;
  16. }
  17.  
  18. @DateTimeFormat(pattern="yyyy-MM-dd")//格式化:前台传递来的数据,将前台传递来到数据 固定为yyyy-MM-dd
  19. private String birthday;
  20.  
  21. public int getAge() {
  22. return age;
  23. }
  24.  
  25. public void setAge(int age) {
  26. this.age = age;
  27. }
  28.  
  29. private int age;
  30.  
  31. public int getId() {
  32. return id;
  33. }
  34.  
  35. public void setId(int id) {
  36. this.id = id;
  37. }
  38.  
  39. public String getName() {
  40. return name;
  41. }
  42.  
  43. public void setName(String name) {
  44. this.name = name;
  45. }
  46.  
  47. public Address getAddress() {
  48. return address;
  49. }
  50.  
  51. public void setAddress(Address address) {
  52. this.address = address;
  53. }
  54.  
  55. }
  1.  

SpringMvc 视图解析器常见功能、类型转换、格式化的更多相关文章

  1. SpringMVC 视图解析器

    SpringMVC 视图解析器 还记得SpringMVC 快速入门中,dispatcher-servlet.xml 配置的视图解析器么.它是SpringMVC 的核心知识点.本章节比较简单,明白视图解 ...

  2. SpringMVC视图解析器

    SpringMVC视图解析器 前言 在前一篇博客中讲了SpringMVC的Controller控制器,在这篇博客中将接着介绍一下SpringMVC视 图解析器.当我们对SpringMVC控制的资源发起 ...

  3. SpringMVC视图解析器(转)

    前言 在前一篇博客中讲了SpringMVC的Controller控制器,在这篇博客中将接着介绍一下SpringMVC视图解析器.当我们对SpringMVC控制的资源发起请求时,这些请求都会被Sprin ...

  4. SpringMVC视图解析器概述

    不论控制器返回一个String,ModelAndView,View都会转换为ModelAndView对象,由视图解析器解析视图,然后,进行页面的跳转. 控制器处理方法---->ModelAndV ...

  5. springmvc 之 SpringMVC视图解析器

    当我们对SpringMVC控制的资源发起请求时,这些请求都会被SpringMVC的DispatcherServlet处理,接着Spring会分析看哪一个HandlerMapping定义的所有请求映射中 ...

  6. springMVC视图解析器——InternalResourceViewResolver(转)

    springmvc在处理器方法中通常返回的是逻辑视图,如何定位到真正的页面,就需要通过视图解析器. springmvc里提供了多个视图解析器,InternalResourceViewResolver就 ...

  7. 深入SpringMVC视图解析器

    ViewResolver的主要职责是根据Controller所返回的ModelAndView中的逻辑视图名,为DispatcherServlet返回一个可用的View实例.SpringMVC中用于把V ...

  8. SpringMVC 视图解析器 InternalResourceViewResolver

    我们在使用SpringMVC的时候,想必都知道,为了安全性考虑,我们的JSP文件都会放在WEB-INF下, 但是我们在外部是不可以直接访问/WEB-INF/目录下的资源对吧, 只能通过内部服务器进行转 ...

  9. SSM-SpringMVC-05:SpringMVC视图解析器InternalResourceViewResolver配置

     ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 视图解析器------默认就有配置,但是默认的在实际使用过程中有很多不方便的地方,所以我们配置一道视图解析器 ...

随机推荐

  1. 一文搞懂vim复制粘贴

    转载自本人独立博客https://liushiming.cn/2020/01/18/copy-and-paste-in-vim/ 概述 复制粘贴是文本编辑最常用的功能,但是在vim中复制粘贴还是有点麻 ...

  2. java篇 之 ==与equals

    ==是一个比较运算符,基本数据类型比较的是值,引用数据类型比较的是地址值. "=="比"equals"运行速度快,因为"=="只是比较引用. ...

  3. Python学习(三)——Python的运算符和数值、字符的类中方法

    Python开发IDE PyCharm,eclipse PyCharm的基础用法 全部选中后 Ctrl+?全部变为注释 运算符 结果为值的运算符 算术运算符: + - * / % // ** 赋值运算 ...

  4. Android学习09

    SharedPreferences SharedPreferences,是一种轻量级的数据存储方式,采用Key/value的方式 进行映射,Sp通常用于记录一些参数配置.行为标记等! 1.获得mSha ...

  5. markdown区块

    Markdown 区块 Markdown 区块引用是在段落开头使用 > 符号 ,然后后面紧跟一个空格符号: > 区块引用 > 菜鸟教程 > 学的不仅是技术更是梦想 显示结果如下 ...

  6. iframe onload事件触发两次

    标准参考 关于 HTML 4.01 规范中 onload 内在事件说明:http://www.w3.org/TR/html401/interact/scripts.html#adef-onload 关 ...

  7. vue项目打包后运行报错400如何解决

    昨天一个Vue项目打包后,今天测试,发现无论localhost还是服务器上都运行不了,报错如下: Failed to load resource: the server responded with ...

  8. 使用PIE.htc 进行IE兼容CSS3

    步骤: 1.引入文件.注意PIE.htc文件和css文件要放在同一个目录下: 2.在css元素中加上  behavior:url(pie.htc); 3.可以愉快的写css hack啦 ,这时需要的圆 ...

  9. coturn服务器配置中英对比

    coturn服务器配置中英对比 默认配置位置 /etc/turnserver.conf # RFC5766-TURN-SERVER configuration file # RFC5766-TURN- ...

  10. 从QC到QA

    QC遇到了什么无法逾越的障碍 我们公司的主要业务是项目外包,一般的项目都在2-3个月的周期,采用瀑布模式.这种模式本身是相对简单,且十分成熟的模式.但是在实际的工作中,我们还是遇到了前所未有的挑战. ...