Sunday, July 4, 2010

jspx EL is not working (Resolved)

I had to expend a long time to understand why EL is not working in my jspx. I tested all the dependencies and jsp files and with differnet different vision of spring distributions. Finlay I understood what the wrong is in my DD. I have given a old declaration which I have copied from some where. I did not believe that will be an issue.


So my advice is use correct XML declaration according to the version that you are using.

I used spring 2.5.6 and used the web xml declaration as below

<?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_2_5.xsd"
version="2.5"

</web-app>

OK keep in mind these declaration is very much improtent in spring context and jspx also.
Spring Context Config XML should have declaration as below.

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

Now in jspx it should be like this.

<?xml version="1.0" encoding='utf-8'?>
<jsp:root version="2.0"
xmlns="http://www.w3c.org/1999/xhtml"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:spring="http://www.springframework.org/tags"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:decorator="http://www.opensymphony.com/sitemesh/decorator"
xmlns:authz="http://www.springframework.org/security/tags"
xmlns:form="http://www.springframework.org/tags/form"
xmlns:c="http://java.sun.com/jstl/core_rt"
xsi:schemaLocation="http://www.w3c.org/1999/xhtml http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd">

No comments:

Post a Comment