日期:2014-05-18 浏览次数:20692 次
package com.gz.koal.sys.tag; import java.io.IOException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.TagSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.gz.koal.model.Useres; import com.opensymphony.xwork.DefaultActionInvocation; /** * 工具栏标签 * @author Administrator * */ public class ToolTag extends TagSupport { private static final long serialVersionUID = 1L; private static final Log LOG = LogFactory.getLog(DefaultActionInvocation.class); private Useres user=null; public static long getSerialVersionUID() { return serialVersionUID; } public Useres getUser() { return user; } public void setUser(Useres user) { this.user = user; } public int doStartTag() { JspWriter out=this.pageContext.getOut(); try { out.println("<div align='right' style='background: #dfdddd'>"); if(user==null) { out.println("<a href='/webwork/jsp/login.jsp' target='_parent'>[登录]</a> "); out.println("<a href='/webwork/jsp/register.jsp' target='_parent'>[注册]</a> "); }else { out.println("<a href='/webwork/jsp/control.jsp' target='_parent'>["+user.getUserName()+"]设置</a>"); out.println("<a href='/webwork/user!undo.action'>[注销]</a> "); } out.println("<a href='/webwork/jsp/index.jsp' target='_parent'>[返回主页]</a>"); out.println("</div><br/>"); } catch (IOException e) { LOG.error("标签文件发生IO流异常"+e.getMessage()); }catch(Exception e) { LOG.error("标签文件发生未知异常"+e.getMessage()); } return SKIP_BODY; } }