我在将javascript文件加载到JSP页面时遇到问题。 相反,css文件正常加载。
在我的* .jsp文件中,我在“标题”部分加载脚本:
<script type="text/javascript" src="js/resources.js" charset="utf-8"></script>
在index.jsp文件的顶部,我指定了字符集:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
还在头部:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
WildFly(第11版)返回的错误是:
Exception handling request to /trust/js/resources.js: java.lang.IllegalArgumentException: Null charset name
“/trust/js/resources.js”是我自己的js文件,我试图加载。
每个* .js文件都会出现此错误
完整的错误堆栈: 15:24:32,670 ERROR [io.undertow.request](默认任务-55)UT005023:对/trust/js/resources.js的异常处理请求:
java.lang.IllegalArgumentException: Null charset name
at java.base/java.nio.charset.Charset.lookup(Charset.java:467)
at java.base/java.nio.charset.Charset.forName(Charset.java:538)
at io.undertow.servlet//io.undertow.servlet.core.BlockingWriterSenderImpl.<init>(BlockingWriterSenderImpl.java:66)
at io.undertow.servlet//io.undertow.servlet.core.ServletBlockingHttpExchange.getSender(ServletBlockingHttpExchange.java:76)
at io.undertow.core//io.undertow.server.HttpServerExchange.getResponseSender(HttpServerExchange.java:1316)
at io.undertow.servlet//io.undertow.servlet.handlers.DefaultServlet.serveFileBlocking(DefaultServlet.java:345)
at io.undertow.servlet//io.undertow.servlet.handlers.DefaultServlet.doGet(DefaultServlet.java:185)
at javax.servlet.api//javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.api//javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet//io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
at deployment.trust-3.1.46.war//eu.dovira.servlet.filter.ServletAccessLogger.doFilter(ServletAccessLogger.java:74)
at io.undertow.servlet//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at deployment.trust-3.1.46.war//eu.dovira.servlet.filter.NocacheFilter.doFilter(NocacheFilter.java:54)
at io.undertow.servlet//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at deployment.trust-3.1.46.war//eu.dovira.servlet.filter.TreeHtmlFilter.doFilter(TreeHtmlFilter.java:50)
at io.undertow.servlet//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at deployment.trust-3.1.46.war//eu.dovira.servlet.filter.RequestEncodingFixer.doFilter(RequestEncodingFixer.java:48)
at io.undertow.servlet//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at deployment.trust-3.1.46.war//eu.dovira.servlet.filter.RouterFilter.doFilter(RouterFilter.java:54)
at io.undertow.servlet//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at deployment.trust-3.1.46.war//eu.dovira.servlet.filter.SetHttpHeadersFilter.doFilter(SetHttpHeadersFilter.java:118)
at io.undertow.servlet//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.core//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.core//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.core//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.core//io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet//io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.core//io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.core//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.core//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.core//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
at io.undertow.core//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
at io.undertow.servlet//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
at io.undertow.servlet//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
at io.undertow.servlet//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
at io.undertow.servlet//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at io.undertow.servlet//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
at io.undertow.servlet//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
at io.undertow.core//io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)
at io.undertow.core//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.base/java.lang.Thread.run(Thread.java:844)
firefox浏览器返回每个js文件(在其开发人员工具包中)的错误,请参见下图: enter image description here
提前感谢所有答案!
答案 0 :(得分:0)
问题在于servlet负责过滤路径。
public static boolean isResourceRequest(String path){
// Images & CSS & JS
if(path.toLowerCase().contains("/img/") || path.contains("/css/") || path.contains("/js/") || path.contains("/upload/") || path.contains("/fonts/")){
return true;
}
return false;
}
我只是通过添加所需的文件类型来改变条件 软件架构师有一个功能。