The function getMessageData must be used with a prefix when a default namespace is not specified [duplicate]

不打扰是莪最后的温柔 提交于 2019-12-19 02:48:07

问题


I am getting this error

/WEB-INF/jsp/account/index.jsp(6,0) The function getMessageData must be used with a prefix when a default namespace is not specified

<c:set var="messageData" scope="session" value="${usermap.getMessageData()}"/>
<c:set var="scheduleData" scope="session" value="${usermap.getScheduleData()}"/>
<c:set var="meetingData" scope="session" value="${usermap.getMeetingData()}"/>

Notice that I can run the same project on local Tomcat without any error.

Tomcat version on server is "Tomcat 6.0"


回答1:


The problem with your code is that the code run locally is run on Tomcat 7 and the code run on the server is run on Tomcat 6.

As soon as invocation of methods with parameters (those ()) is the feature of EL 2.2 (and higher) and it is accompanied by Servlet 3.0 compatible containers (thus Tomcat 7) your code runs fine locally.

As soon as this code is run on a Servlet 2.5 container (thus Tomcat 6) you get the mentioned error.

Still, "property-like" access (without ()) is supported by both servlet containers.




回答2:


Try this:

<c:set var="messageData" scope="session" value="${usermap.messageData}"/>
<c:set var="scheduleData" scope="session" value="${usermap.scheduleData}"/>
<c:set var="meetingData" scope="session" value="${usermap.meetingData}"/>

Reason is, EL removes the "get" and makes the first letter lower-case from your getter methods. Usually there's a field that matches the modified getter name, but it's not necessary.

(Actually, it's more the other way around - when you do usermap.messageData, EL automatically converts it to usermap.getMessageData(). If that method doesn't exist, you'll get an exception.)



来源:https://stackoverflow.com/questions/18961316/the-function-getmessagedata-must-be-used-with-a-prefix-when-a-default-namespace

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!