Using List<Integer> ids to receive a form parameter of HTTP request. The size of the parameter ids is over 255.
Error Info
org.springframework.beans.InvalidPropertyException: Invalid property 'ids[256]' of bean class [com.fantasi.manage.console.web.modules.recovery.dto.RecoveryGroupDto]: Invalid list index in property path 'ids[256]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256.
Solutions
To override init Binder method and configure the limit size which needs so that you can pass those many objects to your controller classes.
SHA256 is difficult to handle than MD5 because of its size.
SHA256 is less secure than MD5
MD5 result in an output of 128 bits whereas SHA256 result output of 256 bits.
Concluding all points, it will be better to use MDA5 if you want to secure your files otherwise you can use SHA256.
Symmetric Encryption Algorithms
DES
DES (data encryption standard, 1976)
DES is Not Secure.
3DES
3DES is Not Secure.
AES
AES (advanced encryption system, 2001)
The AES algorithm has six modes of operation:
ECB (Electronic Code Book) Not Recommend
CBC (Cipher Block Chaining)
CFB (Cipher FeedBack)
OFB (Output FeedBack)
CTR (Counter)
GCM (Galois/Counter Mode)
Don’t use AES Electronic codebook (ECB) Mode. The AES ECB mode, or AES/ECB/PKCS5Padding (in Java) is not semantically secure.
AES encryption best practice: Don’t reuse IV with the same key.
IV
The IV (initial value or initial vector), it is random bytes, typically 12 bytes or 16 bytes. In Java, we can use SecureRandom to generate the random IV.
The AES secret key that derived from a given password. In Java, we can use the SecretKeyFactory and PBKDF2WithHmacSHA256 to generate an AES key from a given password.
// where type = 1 or type = 2 wrapper.and(wrapper -> wrapper.eq("type", 1) .or().eq("type", 2))
// find_in_set(?, category_id) or find_in_set(?, category_id) queryWrapper.and(wrapper -> { for (inti=0; i < categoryIds.size(); i++) { if (i > 0) { wrapper.or(); } wrapper.apply("find_in_set({0}, category_id)", categoryIds.get(i)); } return wrapper; });
// where status = 0 and (type = 1 or (type > 10 and type < 20)) wrapper.eq("status", 0) .and(wrapper -> wrapper.eq("type", 1) .or(wrapper2 -> wrapper2.gt("type", 10) .lt("type", 20));
Pass com.baomidou.mybatisplus.extension.plugins.pagination.Page object as a parameter.
Using the IPage class as the return type.
Don’t need to add limit start, size in mapper XML. The SQL is query all rows. But MyBatis Plus automatically add limit at the end of SQL. If you want to query all, update to List<MyResult> queryAll(@Param("param") MyParam param);
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.druid.initialSize' in value "${spring.datasource.druid.initialSize}" at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178) ... 97 common frames omitted
Solutions
1. Check that the property you need exists in a configuration file. Find out in which configuration file your injected property is.
2. Check whether the property spring.profiles.active value is correct in application.yml. Make sure the active profile is in your project.
3. Check whether your injected property exists in application.yml (or application.properties) and the active profile application-xxx.yml (or application-xxx.properties).
Reasons
The value of the property spring.profiles.active in my application.yml is spring.profiles.active=pro, but I don’t have the application-pro.yml file. The property’s value spring.profiles.active=pro should update to prod.
Java’s standard java.net.URL class and standard handlers for various URL prefixes unfortunately are not quite adequate enough for all access to low-level resources. For example, there is no standardized URL implementation that may be used to access a resource that needs to be obtained from the classpath, or relative to a ServletContext. While it is possible to register new handlers for specialized URL prefixes (similar to existing handlers for prefixes such as http:), this is generally quite complicated, and the URL interface still lacks some desirable functionality, such as a method to check for the existence of the resource being pointed to.
Time cost: BufferedInputStream + Direct Buffer array < Direct Buffer array < Using a BufferedInputStream < Read Method.
Using BufferedInputStream rather than direct buffer is probably “right” for most applications. Because your used buffer size of direct buffer may be worse than BufferedInputStream default buffer size in speed.
Will making the buffer bigger make I/O go faster? Java buffers typically are by default 1024 or 2048 bytes long. A buffer larger than this may help speed I/O, but often by only a few percent, say 5 to 10%.
Problems
Max upload file size
Character encoding of file name
URL encode of file name
Appendixes
Temporary Files and Directories
java.io.tmpdir
System.getProperty("java.io.tmpdir")
Windows 10: C:\Users\{user}\AppData\Local\Temp\
Debian: /tmp
Create temporary file
// If you don't specify the file suffix, the default file suffix is ".tmp". Filefile= File.createTempFile("temp", null); System.out.println(file.getAbsolutePath()); file.deleteOnExit();
Two primary MIME types are important for the role of default types:
text/plain is the default value for textual files. A textual file should be human-readable and must not contain binary data.
application/octet-stream is the default value for all other cases. An unknown file type should use this type. Browsers pay a particular care when manipulating these files, attempting to safeguard the user to prevent dangerous behaviors.
MyBatis is a first class persistence framework with support for custom SQL, stored procedures and advanced mappings. MyBatis eliminates almost all of the JDBC code and manual setting of parameters and retrieval of results. MyBatis can use simple XML or Annotations for configuration and map primitives, Map interfaces and Java POJOs (Plain Old Java Objects) to database records.
MyBatis-Spring integrates MyBatis seamlessly with Spring. This library allows MyBatis to participate in Spring transactions, takes care of building MyBatis mappers and SqlSessions and inject them into other beans, translates MyBatis exceptions into Spring DataAccessExceptions, and finally, it lets you build your application code free of dependencies on MyBatis, Spring or MyBatis-Spring.