1. JavaScript中英文括号转换
  1. function convertBracketsFromZhCn2En(value) {
  2. if(value){
  3. value = value.replace(/(/g,"(");
  4. value = value.replace(/)/g,")");
  5. }
  6. return value;
  7. }
  1. slate

  2. spring mvc controller 参数

  3. ie浏览器用location.hash直接修改hash值的方式来代替history.pushState

  4. IE does not support the http status code 201 Created. Instead, use the standard response for a successful http request, 200 OK.

  1. public ResponseEntity<byte[]> downloadStudentTemplate(HttpServletRequest request,
  2. HttpServletResponse response) throws Exception {
  3. //获取模板地址
  4. String fileName = "学生导入模板.xlsx";
  5. InputStream is = this.getClass().getResourceAsStream("/static/download/student-template.xlsx");
  6. HttpHeaders headers = new HttpHeaders();
  7. //下载显示的文件名,解决中文名称乱码问题
  8. String downloadFielName = java.net.URLEncoder.encode(fileName, "UTF-8");
  9. //通知浏览器以attachment(下载方式)打开图片
  10. headers.setContentDispositionFormData("attachment", downloadFielName);
  11. //application/octet-stream : 二进制流数据(最常见的文件下载)。 “Content-type: application/vnd.ms-excel; name=’Excel'”
  12. headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
  13. return new ResponseEntity<byte[]>(this.readStream(is),
  14. headers, HttpStatus.OK);
  15. }

6.spring assert工具-有助于改善Java代码

  1. notNull(Object object, "object is required") - 对象非空 3hf
  2. isTrue(Object object, "object must be true") - 对象必须为true
  3. notEmpty(Collection collection, "collection must not be empty") - 集合非空
  4. hasLength(String text, "text must be specified") - 字符不为null且字符长度不为0
  5. hasText(String text, "text must not be empty") - text 不为null且必须至少包含一个非空格的字符
  6. isInstanceOf(Class clazz, Object obj, "clazz must be of type [clazz]") - obj必须能被正确造型成为clazz 指定的类
  1. spring boot session timeout 设置

  2. spring shiro session

  3. jdbctemplate in 语句传参的问题

  4. @controllerAdvice通知类

  5. filter、servlet的流程顺序

  6. 开发技术点 - 图1

13.http://tutorials.jenkov.com/java-servlets/servlet-filters.html

  1. 设置Java全局异常处理Thread.setDefaultUncaughtExceptionHandler()

  2. https://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc

  3. https://www.jianshu.com/p/7d1c03625a21

  4. java class转map

  1. public static Map<String, Object> introspect(Object obj) throws Exception {
  2. Map<String, Object> result = new HashMap<String, Object>();
  3. BeanInfo info = Introspector.getBeanInfo(obj.getClass());
  4. for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
  5. Method reader = pd.getReadMethod();
  6. if (reader != null)
  7. result.put(pd.getName(), reader.invoke(obj));
  8. }
  9. return result;
  10. }
  1. java.lang.IllegalArgumentException: Request header is too large
  1. server.xml
  2. <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" maxPostSize="0" maxHttpHeaderSize ="102400"/>
  3. Spring Boot中需要的配置:
  4. application.properties:
  5. server.tomcat.max-http-post-size=2147483647
  1. 前端捕获ajax请求error
  1. //捕获ajax错误
  2. $(document).ajaxError(function (xhr, props) {
  3. log.info(xhr,props);
  4. if (props.readyState !== 4 || props.status !== 200) {
  5. pop.tips("您当前未登录或超时,2秒后将跳转至首页,请重新登录!", function () {
  6. location.href = rootPath;
  7. });
  8. }
  9. });
  1. Ajax关于readyState和status的讨论

  2. readyState

  3. | 0
    未初始化状态:此时,已经创建了一个XMLHttpRequest对象
    1
    准备发送状态:此时,已经调用了XMLHttpRequest对象的open方法,并且XMLHttpRequest对象已经准备好将一个请求发送到服务器端
    2
    已经发送状态:此时,已经通过send方法把一个请求发送到服务器端,但是还没有收到一个响应
    3
    正在接收状态:此时,已经接收到HTTP响应头部信息,但是消息体部分还没有完全接收到
    4
    完成响应状态:此时,已经完成了HTTP响应的接收 | | | | —- | —- | | | | | | | | | | | | |

    | | —- | | | | |

  1. status

  2. | 1XX
    服务器收到请求,需要继续处理。例如101状态码,表示服务器将通知客户端使用更高版本的HTTP协议。
    2XX
    请求成功。例如200状态码,表示请求所希望的响应头或数据体将随此响应返回。
    3XX
    重定向。例如302状态码,表示临时重定向,请求将包含一个新的URL地址,客户端将对新的地址进行GET请求。
    4XX
    客户端错误。例如404状态码,表示客户端请求的资源不存在。
    5XX
    服务器错误。例如500状态码,表示服务器遇到了一个未曾预料的情况,导致了它无法完成响应,一般来说,这个问题会在程序代码出错时出现。 | | | | —- | —- | | | | | | | | | | | | |

    | | —- |

  1. https://www.jianshu.com/p/686ba0ae4ac2

Java程序员必备的Intellij插件

  1. dd

  2. 利用filter和全局ajax事件实现shiro session过期登录跳转http://www.realfond.cn/2017/05/29/%E5%88%A9%E7%94%A8filter%E5%92%8C%E5%85%A8%E5%B1%80ajax%E4%BA%8B%E4%BB%B6%E5%AE%9E%E7%8E%B0shiro%20session%E8%BF%87%E6%9C%9F%E7%99%BB%E5%BD%95%E8%B7%B3%E8%BD%AC/

  3. jquery 捕获所有的ajax请求结果

  1. //全局ajax事件,处理session过期跳转登录
  2. $.ajaxSetup({
  3. complete:function(XMLHttpRequest,status){
  4. log.info("ajaxSetup.complete",XMLHttpRequest,status);
  5. var sessionStatus = XMLHttpRequest.getResponseHeader("session-status");
  6. if(sessionStatus==="timeout"){
  7. pop.tips("您当前未登录或超时,2秒后将跳转至首页,请重新登录!", function () {
  8. location.href = rootPath;
  9. });
  10. }
  11. }
  12. });
  1. java延迟任务执行时间

  2. https://stackoverflow.com/questions/27628106/java-executor-delay-not-working

  3. https://blog.csdn.net/u012402177/article/details/51603034

  4. linux下如何部署(执行)java jar包,并关闭此jar的进程

  5. ```javascript unzip -q suc-u-manage.jar &> /dev/null

nohup java -jar suc-u-manage-dev.jar >suc-u-manage-dev.log 2>&1 &

  1. 35. join
  2. 36. ![](https://cdn.yuque.com/yuque/0/2018/png/102277/1526537085395-5265f392-458e-460f-848c-327a0509d1cd.png#width=600)<br />37.[https://byoungd.gitbooks.io/english-level-up-tips-for-chinese](https://byoungd.gitbooks.io/english-level-up-tips-for-chinese)
  3. 37. java 函数接口
  4. 38. [Spring Boot使用Maven打包替换资源文件占位符](https://www.cnblogs.com/funnyboy0128/p/7693834.html)
  5. 39. spring boot 单元测试忽略某些类文件
  6. 40. profiles,@activeprofiles
  7. 41. [http://gik.firetrot.com/index.php/2016/12/02/exclude-beans-from-tests-in-spring-boot/](http://gik.firetrot.com/index.php/2016/12/02/exclude-beans-from-tests-in-spring-boot/)
  8. 42. [https://stackoverflow.com/questions/39041542/override-a-single-configuration-class-on-every-spring-boot-test?rq=1](https://stackoverflow.com/questions/39041542/override-a-single-configuration-class-on-every-spring-boot-test?rq=1)
  9. 43. spring boot打包 两种方式:打包时确定环境,运行时确定环境
  10. 44. [https://blog.csdn.net/lihe2008125/article/details/50443491](https://blog.csdn.net/lihe2008125/article/details/50443491)
  11. 45. [https://blog.csdn.net/shumoyin/article/details/77321154](https://blog.csdn.net/shumoyin/article/details/77321154)
  12. 46. [https://blog.csdn.net/q397739000/article/details/53037649](https://blog.csdn.net/q397739000/article/details/53037649)
  13. 47. [http://www.cnblogs.com/wenbronk/p/6855973.html](http://www.cnblogs.com/wenbronk/p/6855973.html)
  14. 48. 拷贝不同环境配置文件 [https://www.cnblogs.com/stark-summer/p/4829825.html](https://www.cnblogs.com/stark-summer/p/4829825.html)
  15. 49. 替换配置文件中的占位符${key} 更推荐的方式
  16. ```xml
  17. <build>
  18. <resources>
  19. <resource>
  20. <directory>src/main/resources</directory>
  21. <filtering>true</filtering>
  22. <excludes>
  23. <exclude>xxl-job-admin.properties</exclude>
  24. <exclude>xxl-job-admin-prod.properties</exclude>
  25. <exclude>xxl-job-admin-test.properties</exclude>
  26. <exclude>xxl-job-admin-dev.properties</exclude>
  27. </excludes>
  28. </resource>
  29. <resource>
  30. <directory>src/main/resources</directory>
  31. <filtering>true</filtering>
  32. <includes>
  33. <include>xxl-job-admin-${profile.active}.properties</include>
  34. </includes>
  35. </resource>
  36. </resources>
  37. <plugins>
  38. <plugin>
  39. <groupId>org.apache.maven.plugins</groupId>
  40. <artifactId>maven-resources-plugin</artifactId>
  41. <version>2.7</version>
  42. <configuration>
  43. <useDefaultDelimiters>true</useDefaultDelimiters>
  44. </configuration>
  45. </plugin>
  46. </plugins>
  47. </build>
  1. spring boot 启动脚本指定java版本目录

https://blog.csdn.net/jiyingying_up/article/details/51383872

  1. #!/bin/bash
  2. JAVA_HOME=/home/xinli/jdk1.8.0_92
  3. JAVA=$JAVA_HOME/bin/java
  4. nohup $JAVA -jar yunnan-rest-service-0.1.0.jar -Djava.ext.dirs=$JAVA_HOME/lib &
  1. json文件读取

    1. String jsonStr = new String(IOUtils.readFully(addTaskJson.getInputStream(), -1,true));
    2. JSONObject json = JSONObject.parseObject(jsonStr);
  2. 调度

  3. spring boot resttemplate http://websystique.com/spring-boot/spring-boot-rest-api-example/

  4. http://www.baeldung.com/rest-template

  5. 微服务

  6. 5000所学校监控任务

  7. 数据监控技术选项,restful接口、dubbo服务远程过程调用