1.技术介绍
java+struts+mysql+spring+mybatis+JSP
开发工具:eclipse或idea
2.主要功能说明:
登录
1)管理员
管理员信息管理(新增、修改、删除、查询)
用户信息管理(新增、修改、删除、查询)
车次信息管理(新增、修改、删除、查询)
站台信息管理(新增、修改、删除、查询)
公告信息管理(新增、修改、删除、查询)
评论信息管理(新增、修改、删除、查询)
2)用户
用户注册、登录、查询公交信息、百度地图导航、评论、个人中心
3.核心代码实现:
站台控制器
package com.action;
import java.util.List;
import java.util.Map;
import org.apache.struts2.ServletActionContext;
import com.dao.TCheciDAO;
import com.dao.TGonggaoDAO;
import com.dao.TZhantaiDAO;
import com.model.TCheci;
import com.model.TZhantai;
import com.opensymphony.xwork2.ActionSupport;
public class zhantaiAction extends ActionSupport {
private Integer id;
private Integer checi;
private String zhantai;
private Integer dijizhan;
private String miaoshu;
private String message;
private String path;
private TCheciDAO checiDAO;
private TZhantaiDAO zhantaiDAO;
public TCheciDAO getCheciDAO() {
return checiDAO;
}
public void setCheciDAO(TCheciDAO checiDAO) {
this.checiDAO = checiDAO;
}
public String zhantaiAdd() {
TZhantai zhantaiObj = new TZhantai();
zhantaiObj.setCheci(checi);
zhantaiObj.setDijizhan(dijizhan);
zhantaiObj.setZhantai(zhantai);
zhantaiObj.setMiaoshu(miaoshu);
zhantaiObj.setDel("no");
zhantaiDAO.save(zhantaiObj);
this.setMessage("�����ɹ�");
this.setPath("zhantaiMana.action");
return "succeed";
}
public String zhantaiMana() {
String sql = "from TZhantai where del='no'";
List zhantaiList = zhantaiDAO.getHibernateTemplate().find(sql);
for (Object obj : zhantaiList) {
TZhantai zhantaiObj = (TZhantai) obj;
zhantaiObj.setCheciname(checiDAO.findById(zhantaiObj.getCheci())
.getCheci());
}
Map request = (Map) ServletActionContext.getContext().get("request");
request.put("zhantaiList", zhantaiList);
return ActionSupport.SUCCESS;
}
public String zhantaiBycheci() {
String sql = "from TZhantai where del='no' and checi = " + checi;
List zhantaiList = zhantaiDAO.getHibernateTemplate().find(sql);
for (Object obj : zhantaiList) {
TZhantai zhantaiObj = (TZhantai) obj;
zhantaiObj.setCheciname(checiDAO.findById(zhantaiObj.getCheci())
.getCheci());
}
Map request = (Map) ServletActionContext.getContext().get("request");
request.put("zhantaiList", zhantaiList);
return ActionSupport.SUCCESS;
}
public String zhantaiDel() {
TZhantai zhantai = zhantaiDAO.findById(id);
zhantai.setDel("yes");
zhantaiDAO.attachDirty(zhantai);
this.setMessage("�����ɹ�");
this.setPath("zhantaiMana.action");
return "succeed";
}
public String zhantaiDetail() {
TZhantai zhantai = zhantaiDAO.findById(id);
Map request = (Map) ServletActionContext.getContext().get("request");
request.put("zhantai", zhantai);
return ActionSupport.SUCCESS;
}
public String zhantaiEditPre() {
TZhantai zhantai = zhantaiDAO.findById(id);
Map request = (Map) ServletActionContext.getContext().get("request");
request.put("zhantai", zhantai);
return ActionSupport.SUCCESS;
}
public String zhantaiEdit() {
TZhantai zhantaiObj = zhantaiDAO.findById(id);
zhantaiObj.setCheci(checi);
zhantaiObj.setDijizhan(dijizhan);
zhantaiObj.setZhantai(zhantai);
zhantaiObj.setMiaoshu(miaoshu);
zhantaiDAO.attachDirty(zhantaiObj);
this.setMessage("�����ɹ�");
this.setPath("zhantaiMana.action");
return "succeed";
}
public String zhantaiSerach() {
String sql = "from TZhantai where del='no'";
if (!zhantai.equals("")) {
sql += " and zhantai='" + zhantai + "'";
}
List zhantaiList = zhantaiDAO.getHibernateTemplate().find(sql);
for (Object obj : zhantaiList) {
TZhantai zhantaiObj = (TZhantai) obj;
zhantaiObj.setCheciname(checiDAO.findById(zhantaiObj.getCheci())
.getCheci());
}
Map request = (Map) ServletActionContext.getContext().get("request");
request.put("zhantaiList", zhantaiList);
return ActionSupport.SUCCESS;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getCheci() {
return checi;
}
public void setCheci(Integer checi) {
this.checi = checi;
}
public String getZhantai() {
return zhantai;
}
public void setZhantai(String zhantai) {
this.zhantai = zhantai;
}
public Integer getDijizhan() {
return dijizhan;
}
public void setDijizhan(Integer dijizhan) {
this.dijizhan = dijizhan;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
// public TCheciDAO getCheciDAO() {
// return checiDAO;
// }
//
// public void setCheciDAO(TCheciDAO checiDAO) {
// this.checiDAO = checiDAO;
// }
public TZhantaiDAO getZhantaiDAO() {
return zhantaiDAO;
}
public void setZhantaiDAO(TZhantaiDAO zhantaiDAO) {
this.zhantaiDAO = zhantaiDAO;
}
public String getMiaoshu() {
return miaoshu;
}
public void setMiaoshu(String miaoshu) {
this.miaoshu = miaoshu;
}
}
乘车控制器
package com.action;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.struts2.ServletActionContext;
import com.dao.TCheciDAO;
import com.dao.TGonggaoDAO;
import com.model.TCheci;
import com.opensymphony.xwork2.ActionSupport;
public class checiAction extends ActionSupport {
private int checiId;
private String checi;
private String shifazhan;
private String daodazhan;
private String piaoshijian;
private String startshijian;
private String endshijian;
private int piaojia;
private int piaoshu;
private String message;
private String path;
private TCheciDAO checiDAO;
private TGonggaoDAO gonggaoDAO;
private String startshijian1;// �����װ�ʱ����õ�
private String startshijian2;
public String checiAdd() {
TCheci checiObj = new TCheci();
checiObj.setCheci(checi);
checiObj.setShifazhan(shifazhan);
checiObj.setDaodazhan(daodazhan);
checiObj.setPiaoshijian(piaoshijian);
checiObj.setStartshijian(startshijian);
checiObj.setEndshijian(endshijian);
checiObj.setPiaojia(piaojia);
checiObj.setPiaoshu(piaoshu);
checiObj.setDel("no");
checiDAO.save(checiObj);
this.setMessage("�����ɹ�");
this.setPath("checiMana.action");
return "succeed";
}
public String checiMana() {
String sql = "from TCheci where del='no' order by piaoshijian";
List checiList = checiDAO.getHibernateTemplate().find(sql);
Map request = (Map) ServletActionContext.getContext().get("request");
request.put("checiList", checiList);
return ActionSupport.SUCCESS;
}
public String checiAll() {
String sql = "from TCheci where del='no' order by piaoshijian";
List checiList = checiDAO.getHibernateTemplate().find(sql);
Map request = (Map) ServletActionContext.getContext().get("request");
request.put("checiList", checiList);
return ActionSupport.SUCCESS;
}
public String checiDel() {
TCheci checi = checiDAO.findById(checiId);
checi.setDel("yes");
checiDAO.attachDirty(checi);
this.setMessage("�����ɹ�");
this.setPath("checiMana.action");
return "succeed";
}
public String checiEditPre() {
TCheci checi = checiDAO.findById(checiId);
Map request = (Map) ServletActionContext.getContext().get("request");
request.put("checi", checi);
return ActionSupport.SUCCESS;
}
public String checiEdit() {
TCheci checiObj = checiDAO.findById(checiId);
checiObj.setCheci(checi);
checiObj.setShifazhan(shifazhan);
checiObj.setDaodazhan(daodazhan);
checiObj.setPiaoshijian(piaoshijian);
checiObj.setStartshijian(startshijian);
checiObj.setEndshijian(endshijian);
checiObj.setPiaojia(piaojia);
checiObj.setPiaoshu(piaoshu);
checiDAO.attachDirty(checiObj);
this.setMessage("�����ɹ�");
this.setPath("checiMana.action");
return "succeed";
}
public String checiSerach() {
// System.out.println("^^" + piaoshijian + "^^" + startshijian1 + "^^"
// + startshijian2 + "%%");
// StringBuffer sql = new StringBuffer("from TCheci where del='no'");
// if (!shifazhan.equals("")) {
// sql.append(" and shifazhan like '%" + shifazhan + "%'");
// }
// if (!daodazhan.equals("")) {
// sql.append(" and daodazhan like '%" + daodazhan + "%'");
// }
// if (!checi.equals("")) {
// sql.append(" and checi like'%" + checi + "%'");
// }
//
// System.out.println(sql.toString() + "***");
//
// List checiList = checiDAO.getHibernateTemplate().find(sql.toString());
// System.out.println(checiList.size() + "&&&");
// Map request = (Map) ServletActionContext.getContext().get("request");
// request.put("checiList", checiList);
System.out.println("^^"+piaoshijian+"^^"+startshijian1+"^^"+startshijian2+"%%");
StringBuffer sql=new StringBuffer("from TCheci where del='no'");
Map request=(Map)ServletActionContext.getContext().get("request");
if(!shifazhan.equals("") && !daodazhan.equals("")){
sql.append(" and shifazhan like '%"+shifazhan+"%'").append(" and daodazhan like '%"+daodazhan+"%' ");
List checiListtemp=checiDAO.getHibernateTemplate().find(sql.toString());
if(checiListtemp.size() > 0){
request.put("checiList", checiListtemp);
}else{
StringBuffer sql1=new StringBuffer("from TCheci where del='no'");
sql1.append(" and shifazhan like '%"+shifazhan+"%'").append(" or daodazhan like '%"+daodazhan+"%' ");
List checiList=checiDAO.getHibernateTemplate().find(sql1.toString());
System.out.println(checiList.size()+"&&&");
List checiList2 = new ArrayList();
// for(Object obj: checiList){
// TCheci checiObj = (TCheci) obj ;
// if(shifazhan.equals(checiObj.getShifazhan()) && checiList2.size() < 2){//�ҵ�ʼ��վ
// for(Object obj2: checiList){
// TCheci checiObj2 = (TCheci) obj2 ;
// if(daodazhan.equals(checiObj2.getDaodazhan())){
// checiList2.add(checiObj);
// checiList2.add(checiObj2);
// break ;
// }
// }
// }
for(Object obj: checiList){
TCheci checiObj = (TCheci) obj ;
String daodazhantemp = checiObj.getDaodazhan() ;
if(shifazhan.equals(checiObj.getShifazhan()) && checiList2.size() < 2){//�ҵ�ʼ��վ
for(Object obj2: checiList){
TCheci checiObj2 = (TCheci) obj2 ;
if(daodazhan.equals(checiObj2.getDaodazhan()) && checiObj2.getShifazhan().equals(daodazhantemp)){
checiList2.add(checiObj);
checiList2.add(checiObj2);
break ;
}
}
}
}
request.put("checiList", checiList2);
}
}else{
if(!shifazhan.equals(""))
{
sql.append(" and shifazhan like '%"+shifazhan+"%'");
}
if(!daodazhan.equals(""))
{
sql.append(" and daodazhan like '%"+daodazhan+"%'");
}
if(!checi.equals(""))
{
sql.append(" and checi='"+checi+"'");
}
// if(!startshijian.equals(""))
// {
// sql.append(" and startshijian like '%"+startshijian+"%'");
// }
// if(!endshijian.equals(""))
// {
// sql.append(" and endshijian='"+endshijian+"'");
// }
List checiList=checiDAO.getHibernateTemplate().find(sql.toString());
System.out.println(checiList.size()+"&&&");
// Map request=(Map)ServletActionContext.getContext().get("request");
request.put("checiList", checiList);
}
List gonggaoList = gonggaoDAO.findAll();
if (gonggaoList.size() > 5) {
gonggaoList = gonggaoList.subList(0, 5);
}
request.put("gonggaoList", gonggaoList);
return ActionSupport.SUCCESS;
}
public TCheciDAO getCheciDAO() {
return checiDAO;
}
public String getDaodazhan() {
return daodazhan;
}
public void setDaodazhan(String daodazhan) {
this.daodazhan = daodazhan;
}
public String getShifazhan() {
return shifazhan;
}
public void setShifazhan(String shifazhan) {
this.shifazhan = shifazhan;
}
public void setCheciDAO(TCheciDAO checiDAO) {
this.checiDAO = checiDAO;
}
public int getCheciId() {
return checiId;
}
public void setCheciId(int checiId) {
this.checiId = checiId;
}
public String getEndshijian() {
return endshijian;
}
public void setEndshijian(String endshijian) {
this.endshijian = endshijian;
}
public TGonggaoDAO getGonggaoDAO() {
return gonggaoDAO;
}
public void setGonggaoDAO(TGonggaoDAO gonggaoDAO) {
this.gonggaoDAO = gonggaoDAO;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getPiaoshijian() {
return piaoshijian;
}
public void setPiaoshijian(String piaoshijian) {
this.piaoshijian = piaoshijian;
}
public int getPiaojia() {
return piaojia;
}
public void setPiaojia(int piaojia) {
this.piaojia = piaojia;
}
public int getPiaoshu() {
return piaoshu;
}
public void setPiaoshu(int piaoshu) {
this.piaoshu = piaoshu;
}
public String getStartshijian() {
return startshijian;
}
public void setStartshijian(String startshijian) {
this.startshijian = startshijian;
}
public String getStartshijian1() {
return startshijian1;
}
public void setStartshijian1(String startshijian1) {
this.startshijian1 = startshijian1;
}
public String getStartshijian2() {
return startshijian2;
}
public void setStartshijian2(String startshijian2) {
this.startshijian2 = startshijian2;
}
public String getCheci() {
return checi;
}
public void setCheci(String checi) {
this.checi = checi;
}
}
系统演示地址:
链接:https://pan.baidu.com/s/1PXpjMrTxSOug78cCxWzL4w
提取码:64al



