SetProperty: Mandatory attribute property missing
Ok, first some code. Here's the contents of my 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}
Here's the JSP I'm calling it from (myq.jsp):
<%@page language="java" import="java.util.*,com.serco.inquire.*" %>
<%@ taglib prefix="inq" tagdir="/WEB-INF/tags" %>
<inq:displayCollection mgr="Chris Novish" />
Here's the java class for irCollection (used in the tag file):
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;
}
}
And finally, here's the error I get when i try to run 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)
as far as I can tell, the attribute mgr is set in myq.jsp when it invokes displayCollection.tag, and displayCOllection.tag's only attribute (required) is mgr. so uhm... what do I misunderstand?
Take a closer look at Sun's documentation on the jsp:setProperty
tag. The name
attribute is actually the id
attribute of the bean declared in jsp:useBean
- so it should be "irc
". The property
attribute is required on setProperty
and is the actual property you're trying to set.
精彩评论