?? stationcondition.java
字號:
package com.mvc.Beans;
import java.util.*;
import javax.servlet.http.*;
import org.springframework.jdbc.core.*;
import org.springframework.web.servlet.*;
import org.springframework.web.servlet.mvc.*;
public class stationCondition implements Controller{
public JdbcTemplate jtl;
public JdbcTemplate getJtl() {
return jtl;
}
public void setJtl(JdbcTemplate jtl) {
this.jtl = jtl;
}
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
// TODO Auto-generated method stub
request.setCharacterEncoding("GBK");
String sname=request.getParameter("sname");
String division=request.getParameter("division");
String company=request.getParameter("company");
String ctl=" ";
int label=0;
if(!sname.equals(" ")){
ctl = " sname like '%"+sname+"%' ";
label=1;
}
if(!division.equals(" ") && label==1){
ctl =ctl + " and division like '%"+division+"%' ";
}
if(!division.equals(" ") && label==0){
ctl = " division like '%"+division+"%' ";
label=1;
}
if(!company.equals(" ") && label == 1){
ctl =ctl + " and company like '%"+company+"%' ";
}
if(!company.equals(" ") && label==0){
ctl = " company like '%"+company+"%' ";
label=1;
}
if(label==0){
List list=jtl.queryForList("select * from station");
return new ModelAndView("ListStation","list",list);
}
else{
List list=jtl.queryForList("select * from station where "+ctl+" ");
if(list.isEmpty()){
Map msg = new HashMap();
msg.put("msg", "沒有這一條記錄!");
return new ModelAndView("ConditionStation",msg);
}
return new ModelAndView("ListStation","list",list);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -