Skip to content

Commit 220e342

Browse files
committed
fix servletRequest null
1 parent 8bbfe80 commit 220e342

File tree

1 file changed

+6
-4
lines changed
  • springboot-starter/src/main/java/com/codingapi/springboot/framework/dto/request

1 file changed

+6
-4
lines changed

springboot-starter/src/main/java/com/codingapi/springboot/framework/dto/request/PageRequest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class PageRequest extends org.springframework.data.domain.PageRequest {
2525
private final Map<String, Object> filters = new HashMap<>();
2626

2727
@Getter
28-
private final HttpServletRequest servletRequest;
28+
private HttpServletRequest servletRequest;
2929

3030
private org.springframework.data.domain.PageRequest pageRequest;
3131

@@ -35,9 +35,11 @@ public PageRequest(int current, int pageSize, Sort sort) {
3535
this.pageSize = pageSize;
3636
this.pageRequest = PageRequest.of(current, pageSize, sort);
3737

38-
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
39-
this.servletRequest = attributes.getRequest();
40-
this.syncParameter();
38+
try {
39+
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
40+
this.servletRequest = attributes.getRequest();
41+
this.syncParameter();
42+
}catch (Exception e){}
4143
}
4244

4345

0 commit comments

Comments
 (0)