?? getuserstep.java
字號:
package tags;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;
import db.CustomerOperation;
import java.io.IOException;
import javax.servlet.jsp.tagext.BodyContent;
public class GetUserStep extends BodyTagSupport {
JspWriter out = null;
/**
* 覆蓋doAfterBody()類
*
* @see javax.servlet.jsp.tagext.IterationTag#doAfterBody()
*/
public int doAfterBody() {
// 取得BodyContent對象
BodyContent body = getBodyContent();
// 取得Body中的內(nèi)容
String content = body.getString();
// 取得JspWriter對象
out = body.getEnclosingWriter();
CustomerOperation db = new CustomerOperation();
// 初始化CustomerOperation對象
int userId = Integer.parseInt(content);
// 根據(jù)userId從數(shù)據(jù)庫中查詢該用戶的等級
String name = db.getStep(db.getUser(userId).getUserStrp());
// 關閉數(shù)據(jù)庫的連接
db.Close();
try {
out.print(name);
} catch (IOException e) {
e.printStackTrace();
}
return (SKIP_BODY);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -