Pergunta

I am reading a book and the author uses jspx pages. Instead of jsp:root tag as the root tag he uses div tags with the same namespace declarations as a jsp:root tag. Here is an example :

<div id="header" xmlns:jsp="http://java.sun.com/JSP/Page"
    xmlns:spring="http://www.springframework.org/tags" 
    xmlns:sec="http://www.springframework.org/security/tags" 
    version="2.0">
    <jsp:directive.page contentType="text/html;charset=UTF-8" />
    <jsp:output omit-xml-declaration="yes" />

    <spring:message code="header_text" var="headerText"/>
    <spring:message code="label_logout" var="labelLogout"/>
    <spring:message code="label_welcome" var="labelWelcome"/>
    <spring:url var="logoutUrl" value="/j_spring_security_logout" />        

    <div id="appname">
        <h1>${headerText}</h1>
    </div>

    <div id="userinfo">
        <sec:authorize access="isAuthenticated()">${labelWelcome} 
            <sec:authentication property="principal.username" />
            <br/>
            <a href="${logoutUrl}">${labelLogout}</a>
        </sec:authorize>                    
    </div>  

</div>

The problem is that the editor of my ide (IntelliJ IDEA 12) complains about the version attribute of the div tag by saying that 'Attribute version is not allowed here'. Any ideas? Thank you.

Foi útil?

Solução

I don't use IntelliJ but I guess it checks if the version attribute is allowed in a <div/> tag which it isn't. See http://www.w3schools.com/tags/tag_div.asp. You should use <jsp:root/> instead. Maybe the book was written before JSP 2.0.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top