jsp自定義標籤處理器類----帶屬性標籤的做法
阿新 • • 發佈:2019-01-31
//執行invoke方法,把標籤體內容輸出到指定的writer物件中
//1.2往瀏覽器輸出內容,writer為null就是預設往瀏覽器輸出
/*JspWriter out = this.getJspContext().getOut();
jspBody.invoke(out);
*/
jspBody.invoke(null);//等價上面的程式碼
//控制重複輸出標籤體的內容
//方法:多次呼叫invoke()方法
for(int i = 0; i <= num; i++){
jspBody.invoke(null);
}
//改變標籤體的內容
//1.建立stringwriter臨時容器
StringWriter sw = new StringWriter();
//2.把標籤體拷貝到臨時容器
jspBody.invoke(sw);
//3.從臨時容器中得到標籤體內容
String content = sw.toString();
//4.改變內容
content = content.toLowerCase();
System.out.println(content);
this.getJspContext().getOut().write(content);
throw new SkipPageException();
}
}
//1.2往瀏覽器輸出內容,writer為null就是預設往瀏覽器輸出
/*JspWriter out = this.getJspContext().getOut();
jspBody.invoke(out);
*/
jspBody.invoke(null);//等價上面的程式碼
//控制重複輸出標籤體的內容
//方法:多次呼叫invoke()方法
for(int i = 0; i <= num; i++){
jspBody.invoke(null);
}
//改變標籤體的內容
//1.建立stringwriter臨時容器
StringWriter sw = new StringWriter();
//2.把標籤體拷貝到臨時容器
jspBody.invoke(sw);
//3.從臨時容器中得到標籤體內容
String content = sw.toString();
//4.改變內容
content = content.toLowerCase();
System.out.println(content);
this.getJspContext().getOut().write(content);
throw new SkipPageException();
}
}