jsp页面<a></a>的href值里面的<%%>Java代码怎么用自定义标签代替
tld文件:.<uri>/MyTag</uri><tag><name>adminId</name><tag-class>sedion.ax.rep.tag.GetAdmi...
tld文件:.
<uri>/MyTag</uri>
<tag>
<name>adminId</name>
<tag-class>sedion.ax.rep.tag.GetAdminId</tag-class>
<body-content>empty</body-content>
</tag>
GetDepartName.java:
public int doStartTag() throws JspException {
String departName=(String) pageContext.getSession().getAttribute("departName");
JspWriter out= pageContext.getOut();
try {
out.print(departName);
} catch (Exception e) {
throw new RuntimeException(e);
}
return super.doStartTag();
}
index.jsp:
<%@taglib prefix="c" uri="/MyTag" %> 展开
<uri>/MyTag</uri>
<tag>
<name>adminId</name>
<tag-class>sedion.ax.rep.tag.GetAdminId</tag-class>
<body-content>empty</body-content>
</tag>
GetDepartName.java:
public int doStartTag() throws JspException {
String departName=(String) pageContext.getSession().getAttribute("departName");
JspWriter out= pageContext.getOut();
try {
out.print(departName);
} catch (Exception e) {
throw new RuntimeException(e);
}
return super.doStartTag();
}
index.jsp:
<%@taglib prefix="c" uri="/MyTag" %> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询