我在使用自定义标签和
时遇到问题这是我的tagCalendar
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>tagCalendar</shortname>
<info>Custom Tag Visualizzazione Lista Calendari</info>
<tag>
<name>tagCalendar</name>
<tagclass>it.postecom.postesalute.tag.TagCalendar</tagclass>
<bodycontent>empty</bodycontent>
<info>Custom Tag Visualizzazione Lista Calendari</info>
<attribute>
<name>pageRedirect</name>
<required>true</required>
</attribute>
<attribute>
<name>collectionCalendar</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute><attribute>
<name>actionUrl</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
这是我的JSP片段
<ct:tagCalendar actionUrl="<portlet:actionURL/>" pageRedirect="viewPage" collectionCalendar="<%=QueryCalendar.getUserCalendars(JodUtil.getToken(request))%>" />
和TagCalendar.java的doStartTag方法
try {
JspWriter out = pageContext.getOut();
Iterator iter = collectionCalendar.iterator();
ArrayList <JodBaseCalendar>userCalendarList = new ArrayList<JodBaseCalendar>();
int cnt = 0;
while (cnt <= 3) {
userCalendarList.add((JodBaseCalendar) iter.next());
cnt++;
}
out.println("<table>");
for(JodBaseCalendar calendar:userCalendarList){
out.println("<tr>");
out.println("<a href='"+actionUrl +"?forwardTo="+pageRedirect+"&calendarId="+ calendar.getCalendarId()+"'>");
out.println("["+calendar.getCalendarId()+" - "+calendar.getCalendarSubject()+"]");
out.println("</a>");
out.println("</tr>");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return TagSupport.SKIP_BODY;
标签不会转换为动作,但会像字符串一样使用。
答案 0 :(得分:0)
我以这种方式解决,在jsp页面
<portlet:defineObjects />
<ct:tagCalendar actionUrl="<%= renderResponse.createActionURL().toString() %>" pageRedirect="indexTo" collectionCalendar="<%=QueryCalendar.getUserCalendars(JodUtil.getToken(request))%>" />