Skip to content

Commit

Permalink
Merge pull request #804 from admintertar/compatible-javax-jakarta
Browse files Browse the repository at this point in the history
fix 兼容jakarta/javax的ServletRequest
  • Loading branch information
abel533 authored Jan 30, 2024
2 parents 4a2ce68 + 2abe80f commit 30dd0f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/main/java/com/github/pagehelper/util/ClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,15 @@ public static <T> T newInstance(Class<T> cls, Properties properties) {
}
}

public static Class<?> getServletRequestClass() throws ClassNotFoundException {
Class<?> requestClass = null;
try {
requestClass = Class.forName("javax.servlet.ServletRequest");
}catch (ClassNotFoundException exception){
}
if (requestClass != null){
return requestClass;
}
return Class.forName("jakarta.servlet.ServletRequest");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public abstract class PageObjectUtil {

static {
try {
requestClass = Class.forName("javax.servlet.ServletRequest");
requestClass = ClassUtil.getServletRequestClass();
getParameterMap = requestClass.getMethod("getParameterMap", new Class[]{});
hasRequest = true;
} catch (Throwable e) {
Expand Down

0 comments on commit 30dd0f3

Please sign in to comment.