?? accounttag.java
字號:
package tld;
import javax.servlet.jsp.JspException;
import java.io.IOException;
import src.wuyang.*;
public class AccountTag extends javax.servlet.jsp.tagext.TagSupport{
String showType = "select";
String accountId = "";
public void setShowType(String aShowType) {
showType = aShowType.toLowerCase(); // 變為小寫
}
public void setAccountId(String aAccountId) {
accountId = aAccountId;
}
/**
* Executes when the tag is started.
*/
public int doStartTag() throws JspException {
return SKIP_BODY;
}
/**
* Executed with the end tag.
*/
public int doEndTag() throws JspException {
try {
//pageContext.getOut().print("<h2>Hello from doStartTag()</h2>");
// Allowtext in the body of the tag
Account account = new Account();
if(showType.equals("select")){
account.query("","");
pageContext.getOut().print("<option value=\"" + "\">" + " " + "</option>");
while(account.next()== 1 ) {
pageContext.getOut().print("<option value=\"" + account.getAccountId() + "\">" + account.getEmpName() + "</option>");
}
}else if(showType.equals("get")){
account.load (accountId);
pageContext.getOut().print(account.getEmpName());
}
return EVAL_BODY_INCLUDE;
} catch (IOException e){
throw new javax.servlet.jsp.JspException(e.getMessage());
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -