java – org. apache. jasper. Jasperexception: function tests must be used with prefixes when no default namespace is specified
I am using the following for my project:
@Component @Scope(value = "singleton") public class TestBean { public void test(String param){ System.out.println("param = " + param); } }
I have a JSP page:
<%@page contentType="text/html; charset=utf-8"%> ${testBean.test("hello")}
This code gives me an exception:
If I call some methods without passing arguments – everything is OK
I tried to put JBoss el Jar in my WEB-INF / lib, and put the required parameters in web XML (as described here), but it doesn't work
I'm limited to the set of technologies listed above, so I can't add anything, or, for example, change the version of my application server
With these conditions, is there a solution to my problem?
Solution
This indicates that the environment does not support the new El 2.2 feature of calling bean methods with parameters Outdated environments are trying to interpret expressions as El functions with symbolic namespaces: functionname() (such as JSTL functions) The exception is to complain about the namespace: the part cannot be found to identify the El function But it is wrong after all
You need to ensure that the following conditions are met before calling bean methods with parameters in El:
>The target container must support El 2.2 All servlet 3.0 compatible containers can be made, because El 2.2 is a part of Java EE 6, which is also a part of servlet 3.0 An example of a servlet 3.0 container is Tomcat 7.0 x,Glassfish 3. X and JBoss as 6 x / 7. x. > /WEB-INF/web. XML file declaration conforms to servlet 3.0 specification (so it is not older, such as 2.5)
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <!-- Config here. --> </web-app>
Otherwise, your container will run with web In the fallback schema of the matching version in the XML root declaration, all new servlets 3.0 and El 2.2 will be lost. > Webapp / WEB-INF / lib does not contain container specific El implementation libraries derived from earlier versions of containers, such as Tomcat 6 El API of X Jar and / or El impl Jar or
Your specific problem is caused by the use of non servlet 3.0 compatible containers: old GlassFish 2 x.
Upgrade to GlassFish 3.0 X or look for alternatives JBoss El method is only applicable to JSF, not spring or "plain JSP"