org.apache.jasper.JasperException: The function split must be used with a prefix when a default namespace is not specified

前端 未结 1 1012
忘掉有多难
忘掉有多难 2021-01-14 13:35

the follwong exception is thrown while calling 1st page of my application

org.apache.jasper.JasperException: /WEB-INF/login.jsp(28,21) The function split mus         


        
相关标签:
1条回答
  • 2021-01-14 14:02

    The syntax as you have there (invoking non-getter methods with arguments) is only supported in EL 2.2. You seem not to be targeting a container which supports Servlet 3.0 / JSP 2.2 / EL 2.2 (Tomcat 7, Glassfish 3, etc) or your web.xml seems not to be declared conform Servlet 3.0 spec. Before EL 2.2, the foo() syntax is only recognized as an EL function and it is supposed to be of this form ${prefix:functionName(arg1, arg2)}. That's also what the exception is trying to tell you.

    If you're indeed not targeting a Servlet 3.0 container and/or it is not possible to change the web.xml conform Servlet 3.0, then you need JSTL's fn:split() instead (yes, that's a real EL function):

    <%@ 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>
    
    0 讨论(0)
提交回复
热议问题