1. JSP page cache causes ajax data to not be refreshed and reprinted
https://blog.csdn.net/iteye_12528/article/details/81443986
ServletActionContext.getResponse.setHeader("Cache-Control","no-store");
ServletActionContext.getResponse.setHeader("Pragma","no-cache");
ServletActionContext.getResponse.setDateHeader("Expires", 0);
2.java Resource operation file throws FileNotFoundException
This problem is not easy to find. In development, resource configuration files are generally in folders, so Resource#getFile() is completely fine, but if the configuration file is packaged in a JAR when publishing, then getFile() will Invalid, so read in a streaming manner, which can effectively avoid the impact of the deployment environment
//报错的读取方式
(new DefaultResourceLoader()).getResource("classpath:conf/sys.properties").getFile();
//正确的读取方式
(new DefaultResourceLoader()).getResource("classpath:conf/sys.properties").getInputStream();
3. Get request - special symbol problem
In projects, there are often functions such as verifying strings, such as modifying account passwords.
Get requests in java often cause special symbols that cannot be recognized.
Therefore, it should be noted that such string submission requests need to use post requests.
4. Reference jar to call NoSuchMethodError error, ClassNotFoundException, NoClassDefFoundError
When the jar is updated and called in the project, because the jar is not managed by maven, and other jars from the third party are introduced
ClassNotFound exception: The dependency package is missing in the update jar
NoSuchMethodError error: The referenced package has conflicts
For example:
1.NoSuchMethodError: org.apache.http.conn.ssl.SSLConnectionSocketFactory
This is caused by querying the reference package of SSLConnectionSocketFactory and finding that the current version does not support this method
2. NoClassDefFoundError is followed by the class that reported the error
The situation I encountered was that
A.jar and B.jar were imported. When loading, A.jar contained C1.jar and B.jar contained C2.jar,
resulting in a version conflict of C.jar.
This kind of problem is to confirm which jar package is called.
Provide you with a tool class
and put it directly into the class to see if the called jar is correct.
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
public class SystemUtils {
/**
* 获取一个class类的实际位置
* @param cls
* @return
*/
public static URL getClassLocation(final Class<?> cls) {
//非空判断
if (cls == null) {
throw new IllegalArgumentException("null input: cls");
}
URL result = null;
final String clsAsResource = cls.getName().replace('.', '/').concat(".class");
final ProtectionDomain pd = cls.getProtectionDomain();
if (pd != null) {
final CodeSource cs = pd.getCodeSource();
if (cs != null) {
result = cs.getLocation();
}
if (result != null) {
if ("file".equals(result.getProtocol())) {
try {
if (result.toExternalForm().endsWith(".jar") || result.toExternalForm().endsWith(".zip")) {
result = new URL("jar:".concat(result.toExternalForm()).concat("!/").concat(clsAsResource));
} else if (new File(result.getFile()).isDirectory()) {
result = new URL(result, clsAsResource);
}
} catch (MalformedURLException ignore) {
}
}
}
}
if (result == null) {
final ClassLoader clsLoader = cls.getClassLoader();
result = clsLoader != null ? clsLoader.getResource(clsAsResource) : ClassLoader.getSystemResource(clsAsResource);
}
return result;
}
}
Tool original text: https://www.bbsmax.com/A/RnJW1bEBdq/
5.weblogic startup report: java.lang.ClassCastException: com.octetstring.vde.backend.BackendRoot**
On the Linux server, the root account (should be an ordinary user account) is used to start the weblogic application
When the normal user (weblogic user) starts switching, the exception of the title is reported
Reason: After the root user starts, all kinds of file permissions are given to root permissions, which leads to insufficient permissions to operate files when starting with ordinary users later.
Approach:
find /home/weblogic/ -user root -exec ls {
} \; 查询 /home/weblogic/(此目录是weblogic 的存放目录) 目录下是root 用户权限的文件
chown -R weblogic:weblogic domains 将domains目录下所有的文件,赋值weblogic 用户权限
Repeat the above operation, find the root permission file in the target directory, and re-authorize it
6. The port is occupied under Linux, Address is use
Check the process number occupying the port and kill it (provided that this port number belongs only to you)
ps aux | grep java | losf -i:7001 | grep LISTEN | awk '{print $2}' 查看java 进程,占用7001 端口的 pid
netstat -an | grep LISTEN
0.0.0.0的就是每个IP都有的服务,写明哪个IP的就是绑定那个IP的服务。
netstat -tln
用来查看linux的端口使用情况
netstat -tunllp 查所有的端口
sudo netstat -anp|grep "端口号" ----查使用端口的进程号
kill -9 进程号