📄 feenametag.java
字号:
package tld;
import javax.servlet.jsp.JspException;
import java.io.IOException;
import src.wuyang.*;
public class FeeNameTag extends javax.servlet.jsp.tagext.TagSupport{
String showType = "select";
int feeId =1;
public void setShowType(String aShowType) {
showType = aShowType.toLowerCase(); // 变为小写
}
public void setFeeId(int aFeeId) {
feeId = aFeeId;
}
/**
* 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
FeeName fee = new FeeName();
if(showType.equals("select1")){
fee.query("feeId<20","feeId");
while(fee.next()== 1) {
pageContext.getOut().print("<option value=\"" + fee.getFeeId() + "\">" + fee.getFeeName() + "</option>");
}
}else if(showType.equals("select2")){
fee.query("feeId>20","feeId");
while(fee.next()== 1) {
pageContext.getOut().print("<option value=\"" + fee.getFeeId() + "\">" + fee.getFeeName() + "</option>");
}
}else if(showType.equals("get1")){
fee.query("feeId<20","feeId");
while(fee.next()==1) {
if(fee.getFeeId()==feeId)
pageContext.getOut().print("<option value=\"" + fee.getFeeId() + "\" selected>" + fee.getFeeName() + "</option>");
else
pageContext.getOut().print("<option value=\"" + fee.getFeeId() + "\">" + fee.getFeeName() + "</option>");
}
}else if(showType.equals("get2")){
fee.query("feeId>20","feeId");
while(fee.next()==1) {
if(fee.getFeeId()==feeId)
pageContext.getOut().print("<option value=\"" + fee.getFeeId() + "\" selected>" + fee.getFeeName() + "</option>");
else
pageContext.getOut().print("<option value=\"" + fee.getFeeId() + "\">" + fee.getFeeName() + "</option>");
}
}else if(showType.equals("get")){
fee.query("feeId="+feeId,"");
while(fee.next()==1) {
if(fee.getFeeId()==feeId)
pageContext.getOut().print(fee.getFeeName());
}
}
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 + -