標籤:c class blog java ext http
在jsf1使用 taglib 定義 標籤出現
The absolute uri: http://java.sun.com/jsf/core cannot be resolved in either web.xml or the jar files deployed with this application
的錯誤,後來修改成名稱空間的方式就可以了
原因不明
<html xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
>
<%@ page import="java.util.ArrayList" %><%@ page import="java.util.List" %><%@ taglib prefix="mytag" uri="http://www.hantongchao.com/tag/mytag" %><!-- Created by IntelliJ IDEA. User: han Date: 14-2-26 Time: ????1:32--><%@ page contentType="text/html;charset=UTF-8" language="java" %><% //建立一個List對象 List<String> a = new ArrayList<String>(); a.add("hello"); a.add("world"); a.add("java"); //將List對象放入page範圍內 pageContext.setAttribute("a" , a);%><html xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" > <head><title>Simple jsp page</title></head> <body> <f:view > <h:outputLabel value="Hello, world"/> <mytag:date>time <table border="1" bgcolor="aaaadd" width="300"> <tr> <td>${pageScope.a}</td> <td>${a}</td> <tr> </table> </mytag:date> </f:view> <table border="1" bgcolor="aaaadd" width="300"> <!-- 使用迭代器標籤,對a集合進行迭代 --> <mytag:iterator collection="a" item="item"> <tr> <td>${pageScope.item}</td> <tr> </mytag:iterator> </table> <% //使用pageContext設定屬性,該屬性預設在page範圍內 pageContext.setAttribute("page","hello");//使用request設定屬性,該屬性預設在request範圍內 request.setAttribute("request","hello");//使用pageContext將屬性設定在request範圍中 pageContext.setAttribute("request2","hello" , pageContext.REQUEST_SCOPE);//使用session將屬性設定在session範圍中 session.setAttribute("session","hello");//使用pageContext將屬性設定在session範圍中 pageContext.setAttribute("session2","hello" , pageContext.SESSION_SCOPE);//使用application將屬性設定在application範圍中 application.setAttribute("app","hello");//使用pageContext將屬性設定在application範圍中 pageContext.setAttribute("app2","hello" , pageContext.APPLICATION_SCOPE);//下面擷取各屬性所在的範圍: out.println("page變數所在範圍:" + pageContext.getAttributesScope("page") + "<br>"); out.println("request變數所在範圍:" + pageContext.getAttributesScope("request") + "<br>"); out.println("request2變數所在範圍:"+ pageContext.getAttributesScope("request2") + "<br>"); out.println("session變數所在範圍:" + pageContext.getAttributesScope("session") + "<br>"); out.println("session2變數所在範圍:" + pageContext.getAttributesScope("session2") + "<br>"); out.println("app變數所在範圍:" + pageContext.getAttributesScope("app") + "<br>"); out.println("app2變數所在範圍:" + pageContext.getAttributesScope("app2") + "<br>"); %> </body></html>