SQL插入unicode字符(表情包)

Mysql:
字段编码设置为utf8mb4;

sql server:
1、table定義字段時要用nvarchar
2、insert时指定为unicode(N)
如:
insert into table values (N ‘content ‘)
这里,N表示采用UNICODE编码方式。有N,插入数据库里的是unicode编码(无论是汉字,还是字母,统一用两个字节表示)的数据,这样在不同的系统环境下就会出现乱码,只对字段类型是nvarchar/ntext/nchar的字段有效。
若无N,则按非unicode编码来存储,即汉字是双字节存储,字母单字节存储)。

一个文件夹最多能放多少文件?

FAT32:
Maximum number of files: 268,173,300
Maximum number of files per directory: 216 – 1 (65,535)
Maximum file size: 2 GiB – 1 without LFS, 4 GiB – 1 with
NTFS:
Maximum number of files: 232 – 1 (4,294,967,295)
Maximum file size
Implementation: 244 – 26 bytes (16 TiB – 64 KiB)
Theoretical: 264 – 26 bytes (16 EiB – 64 KiB)
Maximum volume size
Implementation: 232 – 1 clusters (256 TiB – 64 KiB)
Theoretical: 264 – 1 clusters
ext2:
Maximum number of files: 1018
Maximum number of files per directory: ~1.3 × 1020 (performance issues past 10,000)
Maximum file size
16 GiB (block size of 1 KiB)
256 GiB (block size of 2 KiB)
2 TiB (block size of 4 KiB)
2 TiB (block size of 8 KiB)
Maximum volume size
4 TiB (block size of 1 KiB)
8 TiB (block size of 2 KiB)
16 TiB (block size of 4 KiB)
32 TiB (block size of 8 KiB)
ext3:
Maximum number of files: min(volumeSize / 213, numberOfBlocks)
Maximum file size: same as ext2
Maximum volume size: same as ext2
ext4:
Maximum number of files: 232 – 1 (4,294,967,295)
Maximum number of files per directory: unlimited
Maximum file size: 244 – 1 bytes (16 TiB – 1)
Maximum volume size: 248 – 1 bytes (256 TiB – 1)

SQL Server 2008删除db日志

USE AdventureWorks2008R2;
GO
— Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE AdventureWorks2008R2
SET RECOVERY SIMPLE;
GO
— Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2008R2_Log, 1);
GO
— Reset the database recovery model.
ALTER DATABASE AdventureWorks2008R2
SET RECOVERY FULL;
GO
from : http://msdn.microsoft.com/en-us/library/ms189493.aspx

Spring Security的一些资料

Spring Security Authentication Provider

https://dzone.com/articles/spring-security-custom

http://blog.solidcraft.eu/2011/03/spring-security-by-example-user-in.html

http://www.mincoder.com/article/3505.shtml

Spring Security 4 Role Based Login Example

Spring Security 4 Hibernate Role Based Login Example

Spring Security 4 Hibernate Integration Annotation+XML Example

Spring Security 4 Hibernate Integration Annotation+XML Example

用Java代码来代替xml配置spring

Since Spring 3, Java configuration (@Configuration) has been moved into spring-core and has caught my attention. This is a quick sample of how to convert an existing servlet.xml file into a java config file extending WebMvcConfigurerAdapter.

Beginning xml

1. Create the configuration class, I like to create a “config” package with a class named appConfig.java
2. Add @Configuration, this will let spring know this contains bean definitions.

3. Add @EnableWebMVC, this is the same as <mvc:annotation-driven/>

4. Add @ComponentScan(basePackages = {“com.luckyryan.sample”}), this is the same as <context:component-scan base-package=”com.luckyryan.sample”/>

5. Extend the class to use WebMvcConfigurerAdapter. This adds stub implementations from the WebMvcConfigurer interface which is used by @EnableWebMVC. It also gives us a chance to override resources and the default handler.

6. Declare our static resources. I added cache to the java config but it’s not required.

7. Set default servlet handler, this is the same as <mvc:default-servlet-handler/>

8. Add bean for InternalResourceViewResolver

9. Update the servlet declaration in web.xml for the new config class and annotation conf. Note: this replaces the need for <context:annotation-config/> which was not featured in the servlet.xml example.

原文地址:
https://www.luckyryan.com/2013/02/07/migrate-spring-mvc-servlet-xml-to-java-config/

mac下通过Homebrew安装tomcat

首先保证brew命令能够正常使用;

1. 搜索tomcat是否存在:

1
brew search tomcat

2. 安装tomcat:

1
brew install tomcat

3. 检查是否安装成功:

1
catalina -h

4. 运行tomcat:

1
catalina run

Tomcat的默认端口是8080,如果运行成功可通过http://localhost:8080访问
webapp的根目录(CATALINA_HOME)为:/usr/local/Cellar/tomcat/7.0.33/libexec/webapps/ROOT/

POST请求时返回HTTP 417错误

某些网络情况下,当执行POST请求时,会收到一个错误:

The remote server returned an error: (417).

当使用HTTP/1.1 协议进行POST请求时,会在request header里默认增加一项Expect:100-continue,以通知http服务器,在post前,先发一个只有header的请求到目标服务器询问是否可以接收POST过去的数据,如果可以,目标服务器返回100来通知客户端可以继续POST数据。

出现此错误的原因是,代理服务器错误识别目标服务器为HTTP1.0协议不支持100-continue特性,会自动给客户端返回417错误。

解决此方法是,

  • 设置代理服务器正确识别目标服务器的http协议版本;
  • 客户端设置不做询问,直接POST数据过去,不管服务器端是否准备好;

设置代理服务器的方式略。说一下客户端设置的解决方式。

事实上客户端只要在header里指定下Expect不等于100-continue,就可以跳过询问过程。

LINUX/PHP下是这样的。

Windows/ASP.NET下可通过web.config配置或C#代码里设置:

web.config:

C#:

httpWebRequest.ServicePoint.Expect100Continue = false;

附Expect:100-continue的http1.1协议说明:

对HTTP/1.1代理服务器的要求:
— 若代理服务器接到一个请求,此请求包含值为”100-continue”的Expect请求头域,并且代理服务器可能知道下一站点的服务器遵循HTTP/1.1或更高版协议,或者不知道下一站点服务器的HTTP版本,那么它必须包含此Expect头域来转发此请求。
— 若代理服务器知道下一站点服务器版本是HTTP/1.0或更低,则它不能转发此请求,并且它必须以417(期望失败)状态响应。
— 代理服务器应当维护一个缓存,以记录最近访问下一站点服务器的HTTP版本号。
— 若接收到的请求来自于版本是HTTP/1.0(或更低)的客户端,并且此请求不含值为”100-continue”的Expect请求头域,那么代理服务器不能转发100(继续)响应。

http之100-continue

1、http 100-continue用于客户端在发送POST数据给服务器前,征询服务器情况,看服务器是否处理POST的数据,如果不处理,客户端则不上传POST数据,如果处理,则POST上传数据。在现实应用中,通过在POST大数据时,才会使用100-continue协议。

2、客户端策略。

1)如果客户端有POST数据要上传,可以考虑使用100-continue协议。加入头{“Expect”:”100-continue”}

2)如果没有POST数据,不能使用100-continue协议,因为这会让服务端造成误解。

3)并不是所有的Server都会正确实现100-continue协议,如果Client发送Expect:100-continue消息后,在timeout时间内无响应,Client需要立马上传POST数据。

4)有些Server会错误实现100-continue协议,在不需要此协议时返回100,此时客户端应该忽略。

3、服务端策略。

1)正确情况下,收到请求后,返回100或错误码。

2)如果在发送100-continue前收到了POST数据(客户端提前发送POST数据),则不发送100响应码(略去)。

 

 

参照/引用:

  1. Expect:100-Continue & HTTP 417 Expectation
  2. http之100-continue
  3. HTTP详解(3)-http1.0 和http1.1 区别
  4. Expect:100-continue
  5. ServicePointManager Class
  6. http1.1协议