📄 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 + -