📄 employeesalaryhandler.java
字号:
package company;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.util.Hashtable;
import java.io.Writer;
import java.io.IOException;
public class EmployeeSalaryHandler extends TagSupport {
private String mySalary;
private String salary1 = "5,000 RMB";
private String salary2 = "6,000 RMB";
private String salary3 = "7,000 RMB";
public EmployeeSalaryHandler() {
super();
}
/*
Called when the container wants to dispose of the current
tag library.
*/
public void release() {
mySalary = null;
super.release();
}
public void setEmployeeSalary (String salary) {
mySalary=salary;
}
public String getEmployeeSalary () {
return mySalary;
}
public int doStartTag() throws JspException{
/*
You could place any work that you want to have done here.
This method returns a status code. There a number of different
options for these codes, which are discussed later in this
section. This one instructs WebLogic not to evaluate any
expressions inside of the body of the tag.
At this point, you would insert code to go out and
get the stock price from your source. Take that value and
put it into a string variable named 'salaryX',the "X" is from 1 to 3.
*/
try{
JspWriter out = pageContext.getOut();
if(mySalary.equalsIgnoreCase("Bachelor Degree")){
out.print(mySalary + ": " + salary1);
}else if(mySalary.equalsIgnoreCase("Master Degree")) {
out.print(mySalary + ": " + salary2);
}else if(mySalary.equalsIgnoreCase("Doctor Degree")) {
out.print(mySalary + ": " + salary3);
}
}catch (Exception e) {
e.printStackTrace();
throw new JspException(e.getMessage());
}
return(SKIP_BODY);
}
public int doEndTag() throws JspException{
/*
You could place any end work that you want to have done here.
This method returns a status code. There a number of different
options for these codes, which are discussed later in this
section. This one instructs WebLogic not to evaluate any
expressions inside of the body of the tag.
*/ try{
JspWriter out = pageContext.getOut();
out.print(" |Standard:Asia area");
}catch (Exception e) {
e.printStackTrace();
throw new JspException(e.getMessage());
}
return(SKIP_BODY);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -