Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
smthing committed Aug 10, 2024
1 parent 40cd3c5 commit 2d55413
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,8 @@ private void newServletsInstance(DeploymentInfo deploymentInfo) throws Instantia
}
if (servletInfo.getJspFile() != null) {
LOGGER.error("unSupport jsp");
servletInfo.setServlet(new DefaultServlet(deploymentInfo));
servletInfo.setServletClass("org.apache.jasper.servlet.JspServlet");
servletInfo.addInitParam("jspFile", servletInfo.getJspFile());
continue;
}
Servlet servlet = (Servlet) deploymentInfo.getClassLoader().loadClass(servletInfo.getServletClass()).newInstance();
servletInfo.setServlet(servlet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

package tech.smartboot.servlet.handler;

import jakarta.servlet.DispatcherType;
import jakarta.servlet.FilterChain;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
Expand Down Expand Up @@ -78,7 +80,11 @@ private List<FilterInfo> matchFilters(HandlerContext handlerContext) {
allFilters.forEach(filter -> {
filter.getMappings().stream().filter(filterMappingInfo -> filterMappingInfo.getDispatcher().contains(request.getDispatcherType())).forEach(mappingInfo -> {
if (mappingInfo.getMappingType() == FilterMappingType.URL) {
if (PathMatcherUtil.matches(request.getRequestURI(), contextPath.length(), mappingInfo.getServletUrlMapping()) > -1) {
String requestURI = request.getRequestURI();
if (request.getDispatcherType() == DispatcherType.INCLUDE) {
requestURI = (String) request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);
}
if (PathMatcherUtil.matches(requestURI, contextPath.length(), mappingInfo.getServletUrlMapping()) > -1) {
filters.add(filter);
}
} else if (mappingInfo.getMappingType() == FilterMappingType.SERVLET) {
Expand Down

0 comments on commit 2d55413

Please sign in to comment.