小编典典

org.apache.jasper.JasperException:如果未指定默认名称空间,则必须将函数拆分与前缀一起使用

jsp

调用我的应用程序的第一页时引发follwong异常

org.apache.jasper.JasperException: /WEB-INF/login.jsp(28,21) The function split must be used with a prefix when a default namespace is not specified
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Validator$ValidateVisitor$1FVVisitor.visit(Validator.java:1478)
org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:129)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:200)
org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:242)
org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:56)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:200)
org.apache.jasper.compiler.Validator$ValidateVisitor.validateFunctions(Validator.java:1503)
org.apache.jasper.compiler.Validator$ValidateVisitor.prepareExpression(Validator.java:1508)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:724)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:935)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2388)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:838)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1507)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2388)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2394)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
org.apache.jasper.compiler.Validator.validate(Validator.java:1737)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:178)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1157)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:927)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:874)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:779)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:366)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:167)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

login .jsp 在第28行有代码

   26 <select id="tnm" name="tnm" >
   27   <c:forEach items="${temp}" var="i">
   28   <option value='${i.split("#")[0]}'>${i.split("#")[1]}</option>
   29   </c:forEach>                    
   30 </select>

我无法识别为什么引发此异常。任何人都可以告诉我何时抛出此类异常。


阅读 327

收藏
2020-06-08

共1个答案

小编典典

此处使用的语法(使用参数调用非getter方法)仅在EL 2.2中受支持。您似乎没有针对支持Servlet 3.0 / JSP 2.2 / EL
2.2(Tomcat 7,Glassfish 3等)的容器,或者web.xml似乎未声明符合Servlet 3.0规范。在EL
2.2之前,foo()仅将语法识别为EL函数,并且应采用这种形式${prefix:functionName(arg1, arg2)}。这也是异常试图告诉您的内容。

如果您确实没有针对Servlet 3.0容器和/或无法更改web.xml遵循的Servlet 3.0,则需要使用JSTL
fn:split()(是的,这是一个真正的EL函数):

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
...
<c:set var="parts" value="${fn:split(i, '#')}" />
<option value='${parts[0]}'>${parts[1]}</option>
2020-06-08