Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Erro: jsp:attribute must be the subelement of a standard or custom action

itens.jsp


<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="tags"%>

<tags:pageTamplate titulo="Meu Carrinho">

     <jsp:attribute name="extraScripts">
        <script> console.log("Finalização de compra de ${carrinhoCompras.quantidade} itens") </script>
    </jsp:attribute>

<jsp:body>
<!--  código aqui-->
</jsp:body>

</tags:pageTamplate>

pageTemplate.jsp

<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%@ attribute name="bodyClass" required="false"%>
<%@ attribute name="titulo" required="true"%>
<%@ attribute name="extraScripts" fragment="true"%>

<!DOCTYPE html>
<html>
<head>
<c:url value="/resources/css" var="cssPath" />
<link rel="stylesheet" href="${cssPath}/bootstrap.min.css" />
<link rel="stylesheet" href="${cssPath}/bootstrap-theme.min.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${ titulo }</title>
</head>
<body class="${bodyClass}">

    <%@ include file="/WEB-INF/views/cabecalho.jsp"%>

    <jsp:doBody />

    <%@ include file="/WEB-INF/views/rodape.jsp"%>

    <!-- passando fragmento de script -->
    <jsp:invoke fragment="extraScripts"/>

</body>
</html>

erro: 500

ago 10, 2017 6:58:16 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [dispatcher] in context with path [/casadocodigo] threw exception [/WEB-INF/views/carrinho/itens.jsp (line: 16, column: 7) jsp:attribute must be the subelement of a standard or custom action] with root cause
org.apache.jasper.JasperException: /WEB-INF/views/carrinho/itens.jsp (line: 16, column: 7) jsp:attribute must be the subelement of a standard or custom action
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
1 resposta
solução!

Não deve haver conteúdo (nem mesmo um comentário) entre tags:pageTamplate e as tags jsp: attribute. meu Código estava com comentários entre essas tags

<tags:pageTamplate titulo="Meu Carrinho">
<!-- aqui não pode haver conteúdo (nem mesmo comentários)  --> 
     <jsp:attribute >
        <script> </script>
<jsp:body>
<!--  A qui PODE-->
</jsp:body>
    </jsp:attribute>
<!-- Aqui não :D -->
</tags:pageTamplate>

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software