📄 showmyuserinfotag.java
字号:
package com.laoer.bbscs.web.tag;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.*;
import javax.servlet.http.*;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.laoer.bbscs.sys.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.web.servlet.*;
import com.laoer.comm.util.*;
import java.util.*;
/**
* <p>Title: TianYi BBS</p>
* <p>Description: TianYi BBS System</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: LAOER.COM/TIANYISOFT.NET</p>
* @author laoer
* @version 6.0
*/
public class ShowMyUserInfoTag
extends TagSupport {
private String scope = null;
private String name = null;
private String type = null;
private String userCheck = null;
private String form = null;
private String property = null;
public ShowMyUserInfoTag() {
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public int doStartTag() throws JspException {
return (SKIP_BODY);
}
public int doEndTag() throws JspException {
UserCheck uc = (UserCheck) RequestUtils.lookup(pageContext, userCheck,
scope);
/*
WebApplicationContext wac = WebApplicationContextUtils.
getRequiredWebApplicationContext(pageContext.getServletContext());*/
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
if (uc == null) {
HttpServletResponse response = (HttpServletResponse) pageContext.
getResponse();
if (form == null || property == null) {
uc = new UserCheck(request, response);
//uc = new UserCheck(request, response, wac);
}
else {
Object value = RequestUtils.lookup(pageContext, form, property, scope);
uc = new UserCheck(request, response, ( (Long) value).longValue());
//uc = new UserCheck(request, response, wac, ( (Long) value).longValue());
}
}
String output = "";
if (!uc.isGuest()) {
Object value = RequestUtils.lookup(pageContext, name, scope);
UserInfo ui = (UserInfo) value;
if (ui == null || ui.getId() == null) {
UserInfoCache userInfoCache = (UserInfoCache) AppContext.getInstance().
getAppContext().getBean("userInfoCache");
ui = userInfoCache.getUserInfoFromCache(uc.getId());
//return (SKIP_BODY);
}
//else {
//ui = (UserInfo) value;
//}
UserLevel ul = SysUtil.getUserLevel(ui.getExp());
if (type.equals("lastlogintime")) {
output = Util.formatDateTime(new Date(ui.getLastLoginTime()));
}
if (type.equals("level")) {
output = ul.getName();
}
if (type.equals("hpower")) {
output = String.valueOf(ul.getHpower());
}
if (type.equals("pic")) {
StringBuffer sb = new StringBuffer();
if (ui.getHavePic() == 1) {
sb.append("<a href='");
sb.append(SysUtil.getUserFileWebPath(ui.getUsername(),
ui.getId().longValue()));
sb.append(ui.getPicFileName());
sb.append("' target='_blank'><img src='");
sb.append(SysUtil.getUserFileWebPath(ui.getUsername(),
ui.getId().longValue()));
sb.append(ui.getPicFileName());
sb.append("' id='upic_");
sb.append(ui.getId().longValue());
sb.append("' name='upic_");
sb.append(ui.getId().longValue());
sb.append("' border=0 ");
sb.append("onload='javascript:if(this.width>");
sb.append(SysInfo.getInstance().getFacewith());
sb.append("){this.width=");
sb.append(SysInfo.getInstance().getFacewith());
sb.append("}if(this.height>");
sb.append(SysInfo.getInstance().getFacehigh());
sb.append("){this.height=");
sb.append(SysInfo.getInstance().getFacehigh());
sb.append("}'>");
sb.append("</a>");
}
else {
sb.append("<img src='");
sb.append(Constant.DEFAULTPICURL);
sb.append("'>");
}
output = sb.toString();
}
if (type.equals("sign")) {
StringBuffer sb = new StringBuffer();
sb.append(FileIO.readFile(SysUtil.getUserFilePath(ui.getUsername(),
ui.getId().longValue()) + Constant.USERSIGNFILE, Constant.CHARSET));
sb.append("<input type=\"radio\" name=\"sign\" value=\"\" checked>");
sb.append(Constant.MESSAGE.getMessage(request.getLocale(),
"post.nosign"));
output = sb.toString();
}
}
else {
if (type.equals("lastlogintime")) {
output = "";
}
UserLevel ul = SysUtil.getUserLevel(0);
if (type.equals("level")) {
output = ul.getName();
}
if (type.equals("hpower")) {
output = "0";
}
if (type.equals("pic")) {
StringBuffer sb = new StringBuffer();
sb.append("<img src='");
sb.append(Constant.DEFAULTPICURL);
sb.append("'>");
output = sb.toString();
}
}
ResponseUtils.write(pageContext, output);
return (SKIP_BODY);
}
public String getUserCheck() {
return userCheck;
}
public void setUserCheck(String userCheck) {
this.userCheck = userCheck;
}
public String getForm() {
return form;
}
public void setForm(String form) {
this.form = form;
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -