java - Pass XML document via attribute or body to JSP custom tag -
I wonder if an XML document is pure jstl-defined JSP custom tag either: Custom tag body, such as: Or, in the form of a tag attribute such as: This is an auto tag Please note that it is entirely possible to process the body content or an attribute is a non-pure JSTL The link inside (with Java code) is just wondering if such features of JSTL + EL are. EDIT: Resolution It seems that the Netbeans IDE does not have JSTL libraries attached to it by D. No fault. You fix it by libraries - & gt; Add Library- & gt; Import-> Jstl 1.1- & gt; Add Library This works. Actually, your first code block (body usage) works for me as well. If you want to use a file, use the following. and tag file; Regarding your error messages, please tell us which web server you are using. Also, tell which JSTL jar you downloaded and where?
& lt; Mt: mytag & gt; & Lt; People & gt; & Lt; Person's name = "bob" age = "23" /> & Lt; Person's name = "litigation" age = "45" /> & Lt; Person's name = "mo" age = "35" /> & Lt; / People & gt; & Lt; MT: mytag & gt;
& lt; Mt: mytag message = "http: //link.to.document.xml" / & gt;
PWC6197: An error occurred on the line: 9 in jsp file: / WEB-INF / Tags / test2.tag PWC6199: Generated servlet error: javax.servlet.jsp.jstl.core.LoopTagSupport can not access class file for Javax.servlet.jsp.jstl.core.LoopTagSupport not foundPWC6197: one in line Error occurred: In the 9 jsp file: /WEB-INF/tags/test2.tag PWC6199: generated servlet error: Icons Icons can not be found: method setpage syntax (javax.servlet.jsp. PageContext) Location: Variable _jspx_th_x_forEach_0 .......
& lt;% @ taglib tagdir = "/ web-ANF / tag" prefix = "MT"%> & Lt;% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%> & Lt;% @ taglib uri = "http://java.sun.com/jsp/jstl/xml" prefix = "x"%> & Lt; C: set var = "message" & gt; & Lt; People & gt; & Lt; Person's name = "bob" age = "23" /> & Lt; Person's name = "litigation" age = "45" /> & Lt; Person's name = "mo" age = "35" /> & Lt; / People & gt; & Lt; / C: Set & gt; & Lt; Mt: mytag message = "$ {message}" />
& lt;% @ taglib tagdir = "/ WEB-INF / tags" prefix = "mt"%> & Lt; Mt: mytag messageUrl = "http: //link.to.document.xml" />
& lt;% @ tag description = "XML parser" page encoding = "UTF-8"%> & Lt;% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%> & Lt;% @ taglib uri = "http://java.sun.com/jsp/jstl/xml" prefix = "x"%> & Lt;% @ attribute name = "messageUrl"% & gt; & Lt; C: import url = "$ {messageUrl}" var = "message" /> & Lt; X: parse var = "a" doc = "$ {message}" /> & Lt; X: choose forEach var = "current" = "$ a / people / person" & gt; & Lt; Ul & gt; & Lt; Li & gt; Name & lt; X: Select outside = "$ current / name @" /> Age & lt; X: out selection = "$ current / age" /> & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / X: foreach & gt;
Comments
Post a Comment