好的,首先是一些代碼。這裏是我的displayCollection.tag的內容:SetProperty:強制性屬性丟失
<%@ 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}
這裏是我打電話它從JSP(myq.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:強制性屬性 財產丟失 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。編譯器.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。訪問(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 。服務(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)
,據我所知道的,屬性經理在myq.jsp設置時,它調用displayCollection.tag,並displayCOllection.tag的唯一屬性(需要)是mgr。所以呃...我誤解了什麼?