JSP标签的问题请教了
这个是addcoinrecord.jsp的一部分代码:<%session.setAttribute("USERID", "1");%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.buy.bean.coin.AddcoinSelectBean"%>
<%@ page import="java.sql.*"%>
<jsp:useBean id="selectaddcoinBean" class="com.buy.bean.coin.AddcoinSelectBean" scope="request">
</jsp:useBean>
<jsp:setProperty name="selectaddcoinBean" property="s_year" param="s_year" />
<jsp:setProperty name="selectaddcoinBean" property="s_month" param="s_month" />
<jsp:setProperty name="selectaddcoinBean" property="s_day" param="s_day" />
<jsp:setProperty name="selectaddcoinBean" property="e_year" param="e_year" />
<jsp:setProperty name="selectaddcoinBean" property="e_month" param="e_month" />
<jsp:setProperty name="selectaddcoinBean" property="e_day" param="e_day" />
<jsp:setProperty name="selectaddcoinBean" property="type" param="type" />
<jsp:setProperty name="selectaddcoinBean" property="num" param="num" />
..
<td height="85"> <%String ID = (String) session.getAttribute("USERID");
StringBuffer result = selectaddcoinBean.selectAddcoin(ID);%>
<%=result%></td>
......
这是AddcoinSelectBean的类:
public class AddcoinSelectBean {
String s_year= "1700", s_month = "1", s_day= "1", e_year= "2099" ,e_month= "1" ,e_day= "1",type="0",num=null;
public AddcoinSelectBean(){
}
public void setNum(String num) {
this.num = num;
}
public void setType(String type){
this.type = type;
}
public void setS_year(String s_year) {
this.s_year = s_year;
}
public void setS_month(String s_month) {
this.s_month = s_month;
}
public void setS_day(String s_day) {
this.s_day = s_day;
}
public void setE_year(String e_year) {
this.e_year = e_year;
}
public void setE_month(String e_month) {
this.e_month = e_month;
}
public void setE_day(String e_day) {
this.e_day = e_day;
}
public StringBuffer selectAddcoin(String userID){
String type1 = null;
int j = Integer.parseInt(type);
switch (j){
case 0:
type1 = "Any";break;
case 1:
type1 = "在线充值";break;
case 2:
type1 = "个人银行充值";break;
case 3:
type1 = "代理充值";break;
case 4:
type1 = "汇款充值";break;
}
String s_date = s_year + "-" + s_month + "-" + s_day;
String e_date = e_year + "-" + e_month + "-" + e_day;
String condition;
if(num!=null){
condition = "select addid,type,coin,datetime from buy.add where USERID ='"+ userID + "' and addid = "+num+"";
}else{
condition = "select addid,type,coin,datetime from buy.add where USERID ='"+ userID + "' and datetime <= '"+ e_date+ "'and datetime >= '" + s_date +"'";
if(j != 0){
condition += "and type ='"+type1+"'";
}
}
ResultSet rs = null;
String type, coin, date,num;
Statement sql = null;
StringBuffer buffer = new StringBuffer();
try {
Connection conn = DBConnect.getConnection();
sql = conn.createStatement();
rs = sql.executeQuery(condition);
int i = 1;
buffer.append("<table width="+"100%"+" border="+"0"+" cellpadding="+"0"+" cellspacing="+"1"+">");
buffer.append("<tr align=" + "center" + ">");
buffer.append("<td width=" + "190" + "height=" + "25" + " class="
+ "cal_td12" + ">充值编号</td>");
buffer.append("<td width=" + "190" + "height=" + "25" + " class="
+ "cal_td12" + ">充值类型</td>");
buffer.append("<td width=" + "190" + "height=" + "25" + " class="
+ "cal_td12" + ">充值金额</td>");
buffer.append("<td height=" + "25" + " class="
+ "cal_td12" + ">充值时间</td>");
buffer.append("</TR>");
while (rs.next()) {
buffer.append("<tr align=" + "center" + ">");
num = rs.getString(1);//取得第一个字段的值
if(i%2==1){//根据奇偶行显示不同的样式
buffer.append("<TD height=" + "20"
+ " class=" + "cal_td06" + ">" + num + "</TD>");
type = rs.getString(2);//取得第二个字段的值
buffer.append("<TD height=" + "20"
+ " class=" + "cal_td06" + ">" + type + "</TD>");
coin = rs.getString(3);//取得第三个字段的值
buffer.append("<TD height=" + "20"
+ " class=" + "cal_td06" + ">" + coin + "</TD>");
date = rs.getString(4);//取得第四个字段的值
buffer.append("<TD height=" + "20"
+ " class=" + "cal_td06" + ">" + date + "</TD>");
}else{//偶数行的显示
buffer.append("<TD height=" + "20"
+ " class=" + "cal_td08" + ">" + num + "</TD>");
type = rs.getString(2);
buffer.append("<TD height=" + "20"
+ " class=" + "cal_td08" + ">" + type + "</TD>");
coin = rs.getString(3);
buffer.append("<TD height=" + "20"
+ " class=" + "cal_td08" + ">" + coin + "</TD>");
date = rs.getString(4);
buffer.append("<TD height=" + "20"
+ " class=" + "cal_td08" + ">" + date + "</TD>");
}
buffer.append("</TR>");
i++;
}
buffer.append("</Table>");
rs.close();
sql.close();
conn.close();
} catch (SQLException ex) {
System.out.println("TradeDB SQLException: " + ex.getMessage());
return new StringBuffer("查询错误");
}
return buffer;
}
}
我想知道红字标注的代码是什么意思,有什么用处。新到这个网站感觉这里很不错!希望高手指点一下。