companytag.java

来自「(Java+SQL)-大型企业JAVA的ERP系统」· Java 代码 · 共 52 行

JAVA
52
字号
package tld;

import javax.servlet.jsp.JspException;
import java.io.IOException;
import src.wuyang.*;

public class CompanyTag extends javax.servlet.jsp.tagext.TagSupport{

String showType = "select"; 
String companyId = "";
public void setShowType(String aShowType) {
	showType = aShowType.toLowerCase(); // 变为小写
}

public void setCompanyId(String aCompanyId) {
	companyId = aCompanyId;
}


/**
* 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
		Company company = new Company();
		if(showType.equals("select")){
			company.query("","");	
			pageContext.getOut().print("<option value=\"" + "\">" + " " + "</option>");			
			while(company.next()== 1 ) {						
					pageContext.getOut().print("<option value=\"" + company.getCompanyId() + "\">" + company.getCompanyName() + "</option>");		
			}
		}else if(showType.equals("get")){
			company.load (companyId);
			pageContext.getOut().print(company.getCompanyName());
		}	
		return EVAL_BODY_INCLUDE;
	} catch (IOException e){
		throw new javax.servlet.jsp.JspException(e.getMessage());
	}
}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?