10月17
分享一下apache服务器使用htaccess实现301重定向的规则代码。由于nginx服务器对基于动态php语言的wordpress程序执行效率大打折扣,导致服务器cpu常常被php-fpm进程占满卡死,于是我将指南者博客的运行环境切换成了apache,瞬间解决了这个老大难问题!
我的个人博客绑定了很多个域名,但主域名一直是www.heckjj.com,所以需要将其他域名通过301重定向到主域名来避免博客权重的流失。apache与nginx设置301重定向还是有相当大的区别,apache服务器只需将重定向代码保存为名为空后缀为.htaccess的文件,并保存在网站根目录即可。
例子一:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.heckjj.com$ [NC]
RewriteRule ^(.*)$ http://www.heckjj.com/$1 [L,R=301]
以上代码实现了:凡是通过非 www.heckjj.com (第2行中的 www.heckjj.com )访问过来的域名,均会转向到 www.heckjj.com(第3行中的 www.heckjj.com)这个域名;
参数说明:
其中第2行中的 !^www.heckjj.com$ :
! 叹号表示域名的开始;
^ 尖号表示非,即不是以 xxx 开头的;
$ 符号表示域名的结尾。
由此可以看出 !^www.heckjj.com$ 表达的意思就是访问到你服务器的域名不是完全与 www.heckjj.com 相同的域名,就会满足判断的条件,进而触发跳转的操作了。
我的个人博客绑定了很多个域名,但主域名一直是www.heckjj.com,所以需要将其他域名通过301重定向到主域名来避免博客权重的流失。apache与nginx设置301重定向还是有相当大的区别,apache服务器只需将重定向代码保存为名为空后缀为.htaccess的文件,并保存在网站根目录即可。
例子一:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.heckjj.com$ [NC]
RewriteRule ^(.*)$ http://www.heckjj.com/$1 [L,R=301]
以上代码实现了:凡是通过非 www.heckjj.com (第2行中的 www.heckjj.com )访问过来的域名,均会转向到 www.heckjj.com(第3行中的 www.heckjj.com)这个域名;
参数说明:
其中第2行中的 !^www.heckjj.com$ :
! 叹号表示域名的开始;
^ 尖号表示非,即不是以 xxx 开头的;
$ 符号表示域名的结尾。
由此可以看出 !^www.heckjj.com$ 表达的意思就是访问到你服务器的域名不是完全与 www.heckjj.com 相同的域名,就会满足判断的条件,进而触发跳转的操作了。
1月23
有时候会需要在模板中直接打印时间的需求,如果输出一个时间还需要在java类中去获取model的话,那未免也太麻烦了,以下为thymeleaf在模板中直接获取时间戳并格式化输的代码
获取时间戳
格式化时间
注:[[${}]]这种格式为内联,你也可以使用th:text="${}"
以上为直接在thymeleaf中获取时间戳和格式化时间输入的实例
获取时间戳
格式化时间
注:[[${}]]这种格式为内联,你也可以使用th:text="${}"
以上为直接在thymeleaf中获取时间戳和格式化时间输入的实例
12月25
搭建了个springboot项目,使用maven分了几个模块,引用的共用模块中有使用shiro.
但另外一个模块里面是一个独立的Restful接口。不需要用到shiro。一开始的思路是在配置文件中去掉shiro。但是因为shiro的注解已经使用@configuration注入。又不好修改公用代码,于是在springboot的启动类中加入如下代码。问题解决。
第一个注解后面的选项只能摒弃springboot的自动注入类,第二个才是抛弃自定义类的正确方式。
但另外一个模块里面是一个独立的Restful接口。不需要用到shiro。一开始的思路是在配置文件中去掉shiro。但是因为shiro的注解已经使用@configuration注入。又不好修改公用代码,于是在springboot的启动类中加入如下代码。问题解决。
第一个注解后面的选项只能摒弃springboot的自动注入类,第二个才是抛弃自定义类的正确方式。
12月5
Axure版本更新到8.1.0.3377后,原来的授权码不能用了,就在网上重新搜了一下,整理下,留个记录。
Axure RP 8.1.0.3377—-亲测可用
Licensee:
zdfans.com
Key:
gP5uuK2gH+iIVO3YFZwoKyxAdHpXRGNnZWN8Obntqv7++FF3pAz7dTu8B61ySxli
Licensee:
zdfans
Key:
fZw2VoYzXakllUuLVdTH13QYWnjD6NZrxgubQkaRyxD5+HNMqdr+WZKkaa6IoE5N
Licensee:
zd423
Key:
LrZoHQetrL7OK8XOVWgvTFn+XOR32hQkrxkYj0CkbDUsvvENp6GCS38B8GiOS1ec
Axure RP 8.1.0.3377—-亲测可用
Licensee:
zdfans.com
Key:
gP5uuK2gH+iIVO3YFZwoKyxAdHpXRGNnZWN8Obntqv7++FF3pAz7dTu8B61ySxli
Licensee:
zdfans
Key:
fZw2VoYzXakllUuLVdTH13QYWnjD6NZrxgubQkaRyxD5+HNMqdr+WZKkaa6IoE5N
Licensee:
zd423
Key:
LrZoHQetrL7OK8XOVWgvTFn+XOR32hQkrxkYj0CkbDUsvvENp6GCS38B8GiOS1ec
6月13
springboot 自带了jackson来处理时间,但不支持jdk8 LocalDate、LocalDateTime的转换。
对于Calendar、Date二种日期,转换方式有二种:
一、统一application.properties属性配置文件中加入
spring.jackson.dateFormat=yyyy-MM-dd HH:mm:ss
如果你使用了joda第三包下的时间类型,
spring.jackson.jodaDateTimeFormat=yyyy-MM-dd HH:mm:ss
此方法为全局格式,没办法处理差异化。
二、使用jackson的时间注解@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
需要在每个日期类型上都添加,增加代码量,但更灵活性。
以上二方法不能对jdk8 LocalDate、LocalDateTime起作用,还需要添加jackson转换包,在pom.xml添加
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.0</version>
</dependency>
才能生效。
对于Calendar、Date二种日期,转换方式有二种:
一、统一application.properties属性配置文件中加入
spring.jackson.dateFormat=yyyy-MM-dd HH:mm:ss
如果你使用了joda第三包下的时间类型,
spring.jackson.jodaDateTimeFormat=yyyy-MM-dd HH:mm:ss
此方法为全局格式,没办法处理差异化。
二、使用jackson的时间注解@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
需要在每个日期类型上都添加,增加代码量,但更灵活性。
以上二方法不能对jdk8 LocalDate、LocalDateTime起作用,还需要添加jackson转换包,在pom.xml添加
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.0</version>
</dependency>
才能生效。
5月2
在新建多模块maven工程,一般会新建一个parent模块,在该模块pom中会添加打包插件,
<!-- 添加spring-boot的maven插件 -->
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>${java.version}</target>
<source>${java.version}</source>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
当然我们一般还会新建一个通用模块作为工具包之类使用,该模块pom会继承于parent。此时如果parent中pom添加的build插件,没有使用pluginManagement标签,在打包common模块时就会提示找不到main入口。
<!-- 添加spring-boot的maven插件 -->
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>${java.version}</target>
<source>${java.version}</source>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
当然我们一般还会新建一个通用模块作为工具包之类使用,该模块pom会继承于parent。此时如果parent中pom添加的build插件,没有使用pluginManagement标签,在打包common模块时就会提示找不到main入口。
3月8
很多MySQL程序都会带有匿名登录的功能。
在刚刚安装完MySQL之后,就能够登录数据库啦。
这对于平时使用MySQL来说也基本没有什么,可是假设我们想部署数据库的时候。这样的登录方式式绝对不能存在的!试想一下,假设你的数据库随便就能够进入的话,我想你一定会在半夜收到电话,说数据出问题啦!
以下介绍一下删除匿名用户的方式:
首先使用命令进入数据库
[root@localhost raul]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
然后切换数据库,进入我们须要操作的数据库mysql
在刚刚安装完MySQL之后,就能够登录数据库啦。
这对于平时使用MySQL来说也基本没有什么,可是假设我们想部署数据库的时候。这样的登录方式式绝对不能存在的!试想一下,假设你的数据库随便就能够进入的话,我想你一定会在半夜收到电话,说数据出问题啦!
以下介绍一下删除匿名用户的方式:
首先使用命令进入数据库
[root@localhost raul]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
然后切换数据库,进入我们须要操作的数据库mysql
10月18
<repository>
<id>springsource-repos</id>
<name>SpringSource Repository</name>
<url>http://repo.spring.io/release/</url>
</repository>
<repository>
<id>central-repos</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>central-repos2</id>
<name>Central Repository 2</name>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>activiti-repos</id>
<name>Activiti Repository</name>
<url>https://maven.alfresco.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>activiti-repos2</id>
<name>Activiti Repository 2</name>
<url>https://app.camunda.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>thinkgem-repos2</id>
<name>ThinkGem Repository 2</name>
<url>https://raw.github.com/thinkgem/repository/master</url>
</repository>
<id>springsource-repos</id>
<name>SpringSource Repository</name>
<url>http://repo.spring.io/release/</url>
</repository>
<repository>
<id>central-repos</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>central-repos2</id>
<name>Central Repository 2</name>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>activiti-repos</id>
<name>Activiti Repository</name>
<url>https://maven.alfresco.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>activiti-repos2</id>
<name>Activiti Repository 2</name>
<url>https://app.camunda.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>thinkgem-repos2</id>
<name>ThinkGem Repository 2</name>
<url>https://raw.github.com/thinkgem/repository/master</url>
</repository>
9月5
8月25
今天有个同事遇到一个问题,就是用jquerr提交表单时出现问题,提交没反应,非要把按钮类型改成submit的才行,后来发现他的button的id写在submit,在jquery中用这些如submit, length, or method,是会产生冲突可能会导致混乱。
下面是大概的代码
<form id="fm1" action="http://www.heck.tk" method="post">
<h2>请输入您的用户名和密码.</h2>
<div><label for="username">用户名:</label> <input id="username" name="username" type="text" value="" /></div>
<div><label for="password">密码:</label> <input id="password" name="password" type="password" value="" /></div>
<div><label for="custom">自定义:</label> <input id="afterwardsVerify" name="afterwardsVerify" type="text" value="" /></div>
<div><input id="warn" name="warn" value="true" type="checkbox" /> <label for="warn">转向其他站点前提示我。</label></div>
<div>
<input name="submit" value="提交" type="button" onclick="attachedsign() />
</div>
</form>
function attachedsign()
{
var path = "/casPortal/login";
$("#fm1).submit();
}
上面代码看似没问题,但是就是提交不了。于是上jQuery API查找原因:
Additional Notes:
Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint.
翻译过来就是
其他注意事项:
表单和其子元素不宜用一个表单的属性的属性作为name或id的名称,如submit, length, or method,是会产生冲突。名称冲突可能会导致混乱的失败。对于一个完整的规则列表,并检查这些问题标记。
于是上jquery API查找原因,看到以下这段文字顿时明白了:
原来就是这个name=”submit”或者id="submit"的原因.........
下面是大概的代码
<form id="fm1" action="http://www.heck.tk" method="post">
<h2>请输入您的用户名和密码.</h2>
<div><label for="username">用户名:</label> <input id="username" name="username" type="text" value="" /></div>
<div><label for="password">密码:</label> <input id="password" name="password" type="password" value="" /></div>
<div><label for="custom">自定义:</label> <input id="afterwardsVerify" name="afterwardsVerify" type="text" value="" /></div>
<div><input id="warn" name="warn" value="true" type="checkbox" /> <label for="warn">转向其他站点前提示我。</label></div>
<div>
<input name="submit" value="提交" type="button" onclick="attachedsign() />
</div>
</form>
function attachedsign()
{
var path = "/casPortal/login";
$("#fm1).submit();
}
上面代码看似没问题,但是就是提交不了。于是上jQuery API查找原因:
Additional Notes:
Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint.
翻译过来就是
其他注意事项:
表单和其子元素不宜用一个表单的属性的属性作为name或id的名称,如submit, length, or method,是会产生冲突。名称冲突可能会导致混乱的失败。对于一个完整的规则列表,并检查这些问题标记。
于是上jquery API查找原因,看到以下这段文字顿时明白了:
原来就是这个name=”submit”或者id="submit"的原因.........







