![]() |
не работает JSTL
Доброго времени суток!При запуске тега браузер выдаёт следующее:
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 24 in the jsp file: /index.jsp teg cannot be resolved to a type 21: <body> 22: <BODY> 23: <c:set var="login" value="Bender"/> 24: <teg:teg firstname="${login}" /> 25: </BODY> 26: 27: </body> An error occurred at line: 24 in the jsp file: /index.jsp The method get(Class<? extends Tag>) in the type TagHandlerPool is not applicable for the arguments (Class<teg>) 21: <body> 22: <BODY> 23: <c:set var="login" value="Bender"/> 24: <teg:teg firstname="${login}" /> 25: </BODY> 26: 27: </body> Как эту ошибку исправить? код обработчика тега: import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; public class teg extends TagSupport { private String firstname; public void setFirstname(String firstname) { this.firstname = firstname; } @Override public int doStartTag() { try { pageContext.getOut().write("Hello, " + firstname); } catch (IOException e) { e.printStackTrace(); } return SKIP_BODY; } } index.jsp: <%@ taglib uri="/WEB-INF/tlds/teg.tld" prefix="teg"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <!--%@page contentType="text/html" pageEncoding="UTF-8"%--> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <BODY> <c:set var="login" value="Bender"/> <teg:teg firstname="${login}" /> </BODY> </body> </html> teg.tld: <?xml version="1.0" encoding="UTF-8"?> <taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"> <tlib-version>1.0</tlib-version> <short-name>teg</short-name> <uri>/WEB-INF/tlds/teg.tld</uri> <tag> <name>teg</name> <tag-class>teg</tag-class> <body-content>empty</body-content> <attribute> <name>firstname</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag> web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <jsp-config> <taglib> <taglib-uri>/WEB-INF/tlds/teg.tld</taglib-uri> <taglib-location>/WEB-INF/tlds/teg.tld</taglib-location> </taglib> </jsp-config> </web-app> |
ну в общем-то всё,проблему решил всё работает)
а как сделать так,чтобы тег выводил свое содержимое подряд столько раз, сколько указано в атрибуте?и как вообще это в атрибуте указать? |
Время: 07:01. |
Время: 07:01.
© OSzone.net 2001-