gpt4 book ai didi

java - 设置属性 : Mandatory attribute property missing

转载 作者:行者123 更新时间:2023-11-30 09:48:00 25 4
gpt4 key购买 nike

好的,首先是一些代码。这是我的 displayCollection.tag 的内容:

<%@ tag body-content="scriptless" import="com.serco.inquire.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="mgr" required="true" %>
<jsp:useBean id="irc" scope="session" class="com.serco.inquire.irCollection">
<jsp:setProperty name="mgrid" value="${mgr}" />
</jsp:useBean>
${irc.mgrid}

这是我从 (myq.jsp) 调用它的 JSP:

<%@page language="java" import="java.util.*,com.serco.inquire.*" %>
<%@ taglib prefix="inq" tagdir="/WEB-INF/tags" %>
<inq:displayCollection mgr="Chris Novish" />

这是 irCollection 的 java 类(在标记文件中使用):

package com.serco.inquire;
import java.sql.*;
import java.util.*;
public class irCollection {
public String mgrid;
public irCollection() {
super();
}
public void setMgrid(String datum) {
this.mgrid = datum;
}
public String getMgrid() {
return this.mgrid;
}
}

最后,这是我在尝试运行 myq.jsp 时遇到的错误:

org.apache.jasper.JasperException: /WEB-INF/tags/displayCollection.tag(7,2) SetProperty: Mandatory attribute property missing org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198) org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:174) org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:595) org.apache.jasper.compiler.Node$SetProperty.accept(Node.java:1150) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428) org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:647) org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1182) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428) org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434) org.apache.jasper.compiler.Node$Root.accept(Node.java:475) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1789) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:216) org.apache.jasper.compiler.Compiler.compile(Compiler.java:372) org.apache.jasper.compiler.Compiler.compile(Compiler.java:352) org.apache.jasper.compiler.Compiler.compile(Compiler.java:339) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594) org.apache.jasper.servlet.JspServletWrapper.loadTagFile(JspServletWrapper.java:231) org.apache.jasper.compiler.TagFileProcessor.loadTagFile(TagFileProcessor.java:577) org.apache.jasper.compiler.TagFileProcessor.access$000(TagFileProcessor.java:48) org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:642) org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1539) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428) org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434) org.apache.jasper.compiler.Node$Root.accept(Node.java:475) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) org.apache.jasper.compiler.TagFileProcessor.loadTagFiles(TagFileProcessor.java:660) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:228) org.apache.jasper.compiler.Compiler.compile(Compiler.java:372) org.apache.jasper.compiler.Compiler.compile(Compiler.java:352) org.apache.jasper.compiler.Compiler.compile(Compiler.java:339) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

据我所知,属性 mgr 是在调用 displayCollection.tag 时在 myq.jsp 中设置的,而 displayCOllection.tag 的唯一属性(必需)是 mgr。所以嗯...我误解了什么?

最佳答案

仔细看看 Sun 的 documentationjsp:setProperty 标签上。 name 属性实际上是 jsp:useBean 中声明的 bean 的 id 属性 - 所以它应该是 "irc”。 property 属性是 setProperty 所必需的,它是您尝试设置的实际属性。

关于java - 设置属性 : Mandatory attribute property missing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6444063/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com