jsp:attribute 必须是标准或自定义操作的子元素

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

我正在使用 taglib 处理我的 destination.my taglib 文件如下:

 <%@ attribute name="header" fragment="true" required="false" %>
 <%@ attribute name="footer" fragment="true" required="false" %>
 <%@ attribute name="styles" fragment="true" required="false" %>
 <%@ attribute name="scripts" fragment="true" required="false" %>

 <!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="../lib/bootstrap-paper/bootstrap.css" />
    <link rel="stylesheet" href="../lib/toastr/toastr.css" />
    <link rel="stylesheet" href="../lib/sweetalert/dist/sweetalert.css" />
    <link rel="stylesheet" href="../lib/famfamfam-flags/dist/sprite/famfamfam-flags.css" />
    <link rel="stylesheet" href="../lib/slick/slick.css" />
    <link rel="stylesheet" href="../lib/slick/slick-theme.css" />

    <link rel="stylesheet" href="../css/main.css" />
    <link rel="stylesheet"  href="../Content/sweetalert.css"/>
    <%--<jsp:invoke fragment="styles" />--%>
            <script src="//cdn.bootcss.com/angular.js/1.2.9/angular.js"></script>
    <script src="//cdn.bootcss.com/angular.js/1.2.9/angular-route.js"></script>
</head>

<body>
        <div id="pageheader">

        <jsp:invoke fragment="header" />
    </div>
  <div id="body" class="body-content">
<jsp:doBody />
</div>
<div id="pagefooter">
    <jsp:invoke fragment="footer" />
</div>

<jsp:invoke fragment="scripts" />
</body>

我的请求页面如下:

<%@ page language="java" import="java.util.*,com.ppdai.vip.dto.*"   pageEncoding="UTF-8" isELIgnored="false" %>
<%@ page import="com.ppdai.user.tuple.Tuple" %>
<%@ page import="ppdai.user.web.util.PropertyUtil" %>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<%

String title="首页";
   List<HomePageAdDto> bannerList=
        (List<HomePageAdDto>)request.getAttribute("IndexAdBanner");
    List<GoodsTypeDto> goodTypes=(List<GoodsTypeDto>)request.getAttribute("GoodTypes");
   String ssoKey=PropertyUtil.getSsoKey();
   String callBackUrl= PropertyUtil.getCallBackUrl();
  String requestUrl=request.getRequestURL().toString();

%>

 <t:genericpage>

  <%--<jsp:attribute name="styles">--%>
  <%--</jsp:attribute>--%>

  <jsp:attribute name="header">
  <jsp:include page="view/header.jsp" />
  </jsp:attribute>


  <jsp:body>
    1111
</jsp:body>
 <jsp:attribute name="footer">
    <jsp:include page="view/footer.jsp" />
  </jsp:attribute>
 </t:genericpage>

请求springmvc controller的action时出现的异常:

org.apache.jasper.JasperException: /WEB-INF/index.jsp (line: 32, column: 9) jsp:attribute must be the subelement of a standard or custom action
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:275)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:91)
org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1146)
org.apache.jasper.compiler.Parser.parseElementsScriptless(Parser.java:1508)
org.apache.jasper.compiler.Parser.parseBody(Parser.java:1676)
org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1006)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1281)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1460)
org.apache.jasper.compiler.Parser.parse(Parser.java:139)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:227)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

当我刷新页面时,另一个异常会显示给我:

java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.index_jsp

org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.index_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:176)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

我的文件结构是这样的:

我的 pom 引用是这样的:

 <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.2</version>
    </dependency>
 <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
        <scope>compile</scope>
    </dependency>


    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>jstl-api</artifactId>
        <version>1.2</version>

    </dependency>

我解决了,因为我不能在<jsp:body>中包含html和其他代码,使用<jsp:attribute>不会给我错误。