- 博客(66)
- 问答 (3)
- 收藏
- 关注
转载 IntelliJ IDEA中用快捷键自动创建测试类
IntelliJ IDEA中用快捷键自动创建测试类 MathJax.Hub.Config({ showMathMenu: false }); Intell...
2018-02-28 17:03:30 1936
原创 使用 SpringMail +163 邮箱 发送邮件的方法
参考资料:1、163邮箱如何开启POP3/SMTP/IMAP服务? http://help.163.com/10/0312/13/61J0LI3200752CLQ.html2、Spring 邮件服务:Spring+Javamail+Spring SMTP Mail+Maven http://blog.csdn.net/osaymissyou0/article/details/48681...
2018-02-27 21:49:55 2107
原创 使用 Spring Task 定时执行指定的任务
使用注解启动的资料如下:1、使用spring @Scheduled注解执行定时任务、 http://blog.csdn.net/sd4000784/article/details/77459472、spring task 定时任务 注解方式 demo http://blog.csdn.net/eunyeon/article/details/527943083、spring sche...
2018-02-27 21:44:16 1629
原创 Java 使用 Velocity 发送邮件中文内容乱码问题的解决办法
1 spring中整合Velocity的配置文件需要指定UTF-8<!-- velocityEngine 模板 配置开始...--> <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"> <!-- <pr...
2018-02-27 21:28:27 651
原创 使用 Spring 的 JAVA Mail 发送 HTML 邮件
具体的方法参见下面的资料参考资料:1、使用Spring的JAVA Mail支持简化邮件发送 http://www.cnblogs.com/codeplus/archive/2011/11/03/2232893.html2、How do I send HTML email in Spring MVC?https://stackoverflow.com/questions/52898...
2018-02-27 19:43:56 982
转载 使用 163 邮箱发送 javamail 邮件时的错误提示及原因
(1)553 Requested action not taken: Local user only SMTP类型的机器只允许发信人是本站用户; 用户名或密码不正确,并且需要设置如下属性 props.put("mail.smtp.auth", "true");(2)553 Mail from must equal authorized user 发信人地...
2018-02-27 19:42:03 3771
原创 SpringEmail 使用 163 邮箱发送邮件报错 MailAuthenticationException: Authentication failed
Exception in thread “main” org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535 Error: authentication faile...
2018-02-27 16:07:44 1274
原创 git 撤销已经 push 到远端的 commit
使用 git log 查看之前 commit 的版本号git reset --hard 版本号注意,此命令会导致本地代码版本回退为之前 commit 的代码的版本覆盖远端的版本信息git push origin 分知名 --force参考: git撤销已经push到远端的commit http://blog.csdn.net/xs20691718/artic...
2018-02-27 11:44:17 786
原创 git 一次add 多个文件和文件夹的方法
git 一次 add 多个文件的方法git add file_1 file_2 file_3多个文件用 空格 隔开git 提交 文件夹的方法git add catalog_name
2018-02-27 11:40:48 47501 3
原创 报错 NoClassDefFoundError: org/apache/http/config/Lookup 的解决方式
java.lang.ClassNotFoundException: org.apache.http.config.RegistryBuilderhttps://stackoverflow.com/questions/28217891/java-lang-classnotfoundexception-org-apache-http-config-registrybuilder添加此依赖即...
2018-02-27 10:08:26 13050
转载 Intellij IDEA 自动生成 serialVersionUID
Intellij IDEA 自动生成 serialVersionUIDSetting->Inspections->Serialization issues->Serializable class without ’serialVersionUID’ 选上以后,在你的class中:Alt+Enter就会提示自动创建serialVersionUID了。...
2018-02-26 15:30:48 384
原创 使用 requests 模拟用户单点登录的方法
每周开周会的时候,总是因为抢不到会议室使得下班太晚吃不上饭。遂从上个月就产生了一个写一个会议室预定的小脚本。会议室预订系统是公司的一个子系统,公司的各个子系统是通过sso的方式进行登录的,一开始为了偷懒,想用 selenium+phantomjs 随便写一下。可是实际操作了才发现…废话说太多了代码也不可能往上放,放上来了也没用还是说一说思路吧其实思路很简单...
2018-02-25 19:41:52 4648 2
转载 UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multib
python读取文件时提示 “UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0x80 in position 205: illegal multibyte sequence”解决办法1.FILE_OBJECT= open('order.log','r', encoding='UTF-8')解决办法2.FILE...
2018-02-25 19:32:45 552
转载 Python 中将字符串转换为字典的方法
Python 如何将字符串转为字典 Python 如何将字符串转为字典 在工作中遇到一个小问题,需要将一个 python 的字符串转为字典,比如字符串:user_info = '{"name" : "john", "gender" : "male", "age": 28}'我们想把它转为下面的字典:user_dict = {&quo
2018-02-25 19:31:46 75653 8
原创 Linux 中使用 crontab 命令设置定时任务的方法
首先查看一下/etc/crontab文件: $ cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/需要定时启动啥任务就往上写啥写完了就妥了更多的参考资料1、在线Crontab表达式执行时间验证 / crontab执行时间计...
2018-02-25 19:29:30 532
原创 annotation-config, annotation-driven, compont-scan 区别
<context:annotation-config> declares support for general annotations such as @Required, @Autowired, @PostConstruct, and so on. <mvc:annotation-driven /> declares explicit support...
2018-02-25 17:35:54 464
转载 HttpServletRequest常用获取URL的方法
1、request.getRequestURL()返回的是完整的url,包括Http协议,端口号,servlet名字和映射路径,但它不包含请求参数。 2、request.getRequestURI()得到的是request URL的部分值,并且web容器没有decode过的3、request.getContextPath() 返回 the context of the reque...
2018-02-25 16:24:02 1290
原创 web.xml 的 url-pattern / 和 /* 的区别
①<url-pattern>/</url-pattern> 会匹配到/login这样的路径型url,不会匹配到模式为*.jsp这样的后缀型url假设现在请求 localhost:8080/login ,请求到 Controller 下的 /login 跳转到相应的视图 login.jsp ②<url-pattern>/*</ur...
2018-02-25 16:18:44 777
原创 Could not read document: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token
我在使用 RestTemplate 请求 RESTful API ,获取服务端响应的时候出现了这样的一个错误Could not read document: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token最开始的时候是这样写的ResponseEntity<String>...
2018-02-25 16:01:56 16351
原创 localhost、127.0.0.1、本机 ip 三者之间的区别
localhost 是域名,不是地址,在本机的C:\Windows\System32\drivers\etc目录下的 hosts 文件中系统自动的将 localhost 映射到了 127.0.0.1 ,我也同样可以把 aaabbbccc 映射到 127.0.0.1 127.0.0.1 是绑定在 loopback 接口上的地址,如果服务端套接字绑定在它上面,你的客户端程序...
2018-02-25 15:57:35 3431
原创 @ResponseBody 注解设置 utf-8 编码的方式
我最终采用的方式:<bean class = "org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"><property name="messageConverters"> <array> <bean class = "or...
2018-02-25 15:41:35 4821 1
转载 Spring interceptor vs servlet filter 两者之间的区别
SpringMVC的拦截器(Interceptor)和过滤器(Filter)的区别与联系Spring interceptor vs servlet filter一 简介(1)过滤器:依赖于servlet容器。在实现上基于函数回调,可以对几乎所有请求进行过滤,但是缺点是一个过滤器实例只能在容器初始化时调用一次。使用过滤器的目的是用来做一些过滤操作,获取我们想要获取的...
2018-02-25 15:37:08 492
原创 forward( ) 和 sendRedirect()两者之间的区别
两者的区别:1**.redirect** 方式可以跨应用访问,forward 只能在同一个应用中跳转。2.forward 客户端访问服务器,服务器找到要跳转的相应URL并执行返回给客户端。客户端的地址栏显示的是原始URL。redirect 客户端访问服务器,服务器找到要跳转的URL并将URL发给客户端,再由客户端对新的URL重新发送请求。客户端的地址栏显示的是第二次请求的URL...
2018-02-24 20:04:11 520
原创 RestTemplate 的配置方法与基本使用方法
xml 文件中的配置如下(基于 HttpClient): <!-- 基于 HttpClient 的 RestTemplate 配置 --> <!-- begin --> <bean id="pollingConnectionManager" class="org.apache.http.impl.conn.PoolingHttpClien...
2018-02-24 19:56:45 2394
原创 Spring中使用 PropertyPlaceholderConfigurer 替换xml配置文件中的Bean配置项
使用方式<bean id="propertiesConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="true"/>
2018-02-24 19:12:26 909
原创 Sprin g整合 JUnit4 测试时,使用 @ContextConfiguration 注解引入多个配置文件
一般情况下:@ContextConfiguration(Locations="../applicationContext.xml") 多个文件时,可用{}@ContextConfiguration(locations = { "classpath*:/spring1.xml", "classpath*:/spring2.xml" }) 依赖<depe...
2018-02-24 18:26:16 20357 1
转载 java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException
When I run junit test, encountered this error: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingExceptionSolution: add the following dependencies:<dependency> ...
2018-02-24 18:12:59 736
原创 使用 flask 实现一个简单的可以返回 json 的 RESTful API 服务端
UpmApi.pyfrom flask import Flaskfrom flask import jsonifyimport randomapp = Flask(__name__)@app.route('/')def hello_world(): return 'Hello World!'@app.route('/user/check', methods=["GE...
2018-02-24 18:07:14 3663 1
原创 一个使用 Spring 拦截器进行登录拦截的小 Demo
CheckLoginInterceptor.javaimport org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.servlet.HandlerInterceptor;import org.springframework.web.servlet.ModelAndVi...
2018-02-24 17:55:15 928
原创 Intellij IDEA 报错 Cannot open URL. Please check this URL is correct: http://localhost:8080/
报错状况参考出现原因检查 Tomcat 配置我这里报错的原因是 open browser 和 Tomcat Server Settings -》 HTTP port 设置的不一致当时上边写的是 8888,下边写的是 8080,以至于出现此种错误...
2018-02-24 17:39:23 23260 18
原创 使用 fastjson 解析嵌套的 json 数据
假设现在有这样一个 JSONObject{ "data": { "is_admin": false, "app_id": 10, "user": { "id": "2xxxxx", "phone": "186xxxxxx",
2018-02-24 17:19:15 4681
原创 SpringMVC 配置拦截器 mvc:exclude-mapping 报错的解决办法
我遇到的错误是这样的试了以下几篇文章中的几种解决方式1、配置拦截器报-发现了以元素 ‘mvc:exclude-mapping’ 开头的无效内容的错误 http://blog.csdn.net/yangfan321p/article/details/788545642、【SpringMVC】SpringMVC配置拦截器 mvc:exclude-mapping 报错 http:...
2018-02-24 16:39:55 1565
原创 使用 RestTemplate 发送 post 请求后返回 json 中 ":" 变成 "=" 的解决办法
打算使用 RestTemplate 替换别人封装的 HttpClient ,但是在测试的过程中发现了一个问题。发现返回的 json 的格式中,HttpClient 返回的 json 是 正常的冒号,而 RestTemplate 返回的 json 却是 异常的等号。解决办法将 Object.class替换成 JSONObject.class即可...
2018-02-24 14:57:14 6140
原创 使用 RestTemplate 发送 post 请求传递参数
注意:post 请求的参数不能用 HashMap 封装,应该使用 MultiValueMap写法参考HttpHeaders headers = new HttpHeaders();headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);MultiValueMap<String, String> m...
2018-02-24 14:26:43 39054 3
原创 noHandlerFound:org.springframework.web.servlet.DispatcherServlet.noHandlerFound
DispatcherServlet.java(noHandlerFound:org.springframework.web.servlet.DispatcherServlet.noHandlerFound(DispatcherServlet.java:1147)) - No mapping found for HTTP request with URI [/WEB-INF/jsp/hello...
2018-02-23 18:50:49 1299
原创 解决 Log4jConfigListener 过期问题
spring建议用log4j2 来替换这个类。以下为官方原文Deprecated. as of Spring 4.2.1, in favor of Apache Log4j 2 (following Apache's EOL declaration for log4j 1.x)@Deprecatedpublic class Log4jConfigListenerextends j...
2018-02-23 17:56:09 3914 3
原创 log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
Log4j, Spring MVC, No appenders could be found for loggerhttps://stackoverflow.com/questions/9691456/log4j-spring-mvc-no-appenders-could-be-found-for-loggerlog4j:WARN No appenders could be found...
2018-02-23 17:51:58 3148
原创 Intellij IDEA 自动清除无效 import 和 清除无效 import 的快捷键
快捷键 ctrl+alt+o自动清除的配置方法 可以settings-general-auto import-java项,勾选optimize imports on the fly,在当前项目下会自动清除无效的import,而且这个是随时自动清除的。参考资料1、使用idea一次性清理所有java文件中多余导入未使用的包 http://blog.csdn...
2018-02-23 15:30:54 82764 8
原创 配置管理库 typesafe.config 的简单使用
SimpleLibContext.javapackage config_lib;/** * Author: HeatDeath * Date: 2018/2/23 * Desc: */import com.typesafe.config.Config;import com.typesafe.config.ConfigFactory;// Whenever you ...
2018-02-23 15:20:12 5292
转载 Intellij 提示 usage of api documented as @since 1.6+ 的解决办法
Intellij IDEA 出现“Usage of API documented as @since 1.6+”的解决办法Intellij - Unable to use newer Java 8 classes - Error : “Usage of API documented as @since 1.6+..”IntelliJ IDEA使用教程 (总目录篇)具体报错内...
2018-02-23 13:07:04 495
空空如也
汇编求两个任意位数的十进制数字的差,并输出。结果总是输出10进制的补码是什么情况
2016-04-25
汇编将输入的十进制数字转换成二进制,八进制,十六进制,代码写出来了,但是却无法正常运行
2016-04-21
初学者的一点疑问,汇编语言计算两个输入数字的和并输出
2016-04-06
TA创建的收藏夹 TA关注的收藏夹
TA关注的人