<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ page isELIgnored="false"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ taglib prefix="js" uri="http://www.jsoft.com/jsoftTag"%> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'showList.jsp' starting page</title> <link rel="stylesheet" type="text/css" href="<%=basePath%>Admin/Css/defaultCss.css"> <link rel="stylesheet" type="text/css" href="<%=basePath%>WebControl/SubPage/default.css"> <mce:script type="text/javascript" src="<%=basePath%><!-- WebTools/JavaScript/jquery.js"> // --></mce:script> <mce:script type="text/javascript"><!-- function form_delete(href) { if(confirm("您真的要删除此事件吗?删除后此事件将无法恢复!")) { window.location.href = href; } } //------------ function huanbga(obj) { obj.style.background="#D7F3FD"; obj.style.cursor = "pointer"; } function huanbgs(obj) { obj.style.background="#FFFFFF"; } //----------------- function selectChange(obj) { $("#bigName").val(obj.options[obj.selectedIndex].text); var itemName = obj.id; var itemValue = obj.value; var httpPath = "<%=basePath%>Dic/Ajax/smallclass.jhtml?random="+Math.random()+"&parent="+obj.value; //alert(httpPath); $.get(httpPath, null, showHttp); } function showHttp(data) { var msg = ""; msg += "<option value=/"0/">"; msg += "-请选择-"; msg += "</option>"; try { data = data.replace(/(/r/n|/n)/ig,''); var j = eval("(" + data + ")"); itemJson = j; len = j.objs.length; for (i = 0; i < len; i++) { itemId = j.objs[i].id; itemName = j.objs[i].name; msg += "<option value=/""+itemId+"/">"; msg += itemName; msg += "</option>"; } } catch (e) { } $("#smallId").html(msg); } function setHiden(obj) { $("#smallName").val(obj.options[obj.selectedIndex].text); } function showImgPath(path) { $("#imgPath").val(path); } // --></mce:script> </head> <body> <table width="100%" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD"> <tr bgcolor="#EEEEEE"> <th align="left"> 学校列表 <font color="red"><c:out value="${requestScope.saveErr}" /> </font> </th> </tr> <tr bgcolor="#FFFFFF"> <td> <table width="100%" cellpadding="2" cellspacing="1" border="0" bgcolor="#EEEEEE"> <tr bgcolor="#F7F495"> <td>编号</td> <td>学校名称</td> <td>学校英文名</td> <td>学校网址</td> <td>学校性质</td> <td>学校类型</td> <td>是否推荐</td> <td>操作</td> </tr> <c:forEach items="${requestScope.schools}" var="school"> <tr bgcolor="#FFFFFF"> <td><c:out value="${school.id}"/></td> <td><c:out value="${school.name}"/></td> <td><c:out value="${school.engName}"/></td> <td><c:out value="${school.href}"/></td> <td><c:out value="${school.natureName}"/></td> <td><c:out value="${school.typeName}"/></td> <td> <c:choose> <c:when test="${school.recom eq 0}"> <font color="red">不推荐</font> </c:when> <c:when test="${school.recom eq 1}"> <font color="blue">推荐</font> </c:when> <c:otherwise> <font color="#000000">未知</font> </c:otherwise> </c:choose> </td> <td> <a href="<%=basePath%>act/add-${school.id}.jhtml">新增活动</a> | <a href="<%=basePath%>managerSchool/edit-${school.id}.jhtml">编辑</a> | <a href="javascript:form_delete('<%=basePath%>managerSchool/delete-${school.id}.jhtml');">删除</a> </td> </tr> </c:forEach> </table> <js:SubPage styleClass="manu"/> </td> </tr> </table> </body> </html> package org.web.dbo.dao.imp; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; import java.util.ArrayList; import com.jsoft.log.Logger; import com.jsoft.dao.DaoSupport; import org.web.dbo.vo.School; /** * CreateTime:2010-03-22 10:56:23 * @author AutoCreater(Jsoft) * */ public class SchoolDaoImp extends DaoSupport<School> { /** * Look for a collection of all objects, return: Object List. * @author AutoCreater(Jsoft) * @param * @return List<School> */ public List<School> findAllObj() { List<School> objs = null; String sql = "SELECT * FROM school"; Connection conn = getConnection(); PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(sql); rs = ps.executeQuery(); if (rs.next()) { objs = new ArrayList<School>(); do { School obj = new School(); obj.setId(rs.getInt("id")); obj.setName(rs.getString("name")); obj.setEngName(rs.getString("engName")); obj.setGoogleMap(rs.getString("googleMap")); obj.setHref(rs.getString("href")); obj.setNotes(rs.getString("notes")); obj.setNature(rs.getInt("nature")); obj.setCreateYear(rs.getInt("createYear")); obj.setRegStus(rs.getInt("regStus")); obj.setRegional(rs.getString("regional")); obj.setCity(rs.getString("city")); obj.setAirport(rs.getString("airport")); obj.setNotesText(rs.getString("notesText")); obj.setState(rs.getInt("state")); obj.setLogoImg(rs.getString("logoImg")); obj.setImage(rs.getString("image")); obj.setType(rs.getInt("type")); obj.setRecom(rs.getInt("recom")); obj.setCreateTime(rs.getTimestamp("createTime")); obj.setTimeName(rs.getString("timeName")); objs.add(obj); } while (rs.next()); } } catch (SQLException e) { Logger.getLogger().writerLog("findAllObj:["+getClass().getName()+"]"+e.getMessage()); e.printStackTrace(); } finally { closeAll(rs, ps, null, conn); } return objs; } package org.web.service.imp.system; import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.web.dbo.dao.imp.ActivitiesDaoImp; import org.web.dbo.dao.imp.RanktypeDaoImp; import org.web.dbo.dao.imp.SchoolDaoImp; import org.web.dbo.dao.imp.School_rankDaoImp; import org.web.dbo.vo.Activities; import org.web.dbo.vo.Ranktype; import org.web.dbo.vo.School; import org.web.dbo.vo.School_rank; import org.web.service.ServiceFactory; import org.web.service.system.DicVoService; import org.web.service.system.SchoolService; import com.jsoft.sql.SessionFactory; import com.jsoft.util.DateUtil; import com.jsoft.web.taglib.vo.PageModel; public class SchoolServiceImp implements SchoolService { public School findSchool(String schoolId) { // TODO Auto-generated method stub School obj = null; SessionFactory.openConnection(); SchoolDaoImp schoolDao = new SchoolDaoImp(); try { obj = schoolDao.findObjById(Integer.parseInt(schoolId)); } catch (Exception e) { obj = null; } setSchoolCache(obj, null); SessionFactory.closeConnection(); return obj; } package org.web.service.system; import java.util.List; import org.web.dbo.vo.Activities; import org.web.dbo.vo.Ranktype; import org.web.dbo.vo.School; import org.web.dbo.vo.School_rank; import com.jsoft.web.taglib.vo.PageModel; public interface SchoolService { public School findSchool(String schoolId); } <?xml version="1.0" encoding="UTF-8"?> <views> <action-mappings> <!-- SchoolAction --> <action path="/school" param="path" scope="request" class="org.web.action.main.SchoolAction"> <forward name="show" path="/School/showSchool.jsp" /> <forward name="engSchool" path="/School/engSchool.jsp" /> <forward name="t-engSchool" path="/School/tEngSchool.jsp" /> <forward name="engCollege" path="/School/engCollege.jsp" /> <forward name="t-engCollege" path="/School/tEngCollege.jsp" /> <forward name="engMidSchool" path="/School/engMidSchool.jsp" /> <forward name="t-engMidSchool" path="/School/tEngMidSchool.jsp" /> <forward name="engSchoolNews" path="/School/engSchoolNews.jsp" /> <forward name="t-engSchoolNews" path="/School/tEngSchoolNews.jsp" /> <forward name="error" path="/Error/error.jsp" redirect="true" /> </action> </views> package org.web.action.main; import java.util.List; import org.web.dbo.vo.Bigclass; import org.web.dbo.vo.News; import org.web.dbo.vo.School; import org.web.dbo.vo.School_rank; import org.web.dbo.vo.Smallclass; import org.web.service.imp.system.NewsServiceImp; import org.web.service.imp.system.SchoolServiceImp; import org.web.service.system.NewsService; import org.web.service.system.SchoolService; import com.jsoft.web.ActionSupport; public class SchoolAction extends ActionSupport { private String path; @Override public String execute() { // TODO Auto-generated method stub String forward = null; if (path != null) { String[] temp = this.path.split("-"); if(temp.length == 1) { if("engSchool".equals(temp[0]) || "engSchool_main".equals(temp[0])) { SchoolService schoolService = new SchoolServiceImp(); //String sql = "select * from school"; List<School> schools = schoolService.findSchoolRankListByYear(38,"2011"); this.getRequest().setAttribute("schools", schools); initLeft(); if("engSchool".equals(temp[0])) { this.getRequest().setAttribute("school_label", "英国大学"); } else if("engSchool_main".equals(temp[0])) { this.getRequest().setAttribute("school_label", "英国院校"); } this.getRequest().setAttribute("pathUrl", temp[0]); forward = "engSchool"; } else if("tEngSchool".equals(temp[0]) || "tEngSchool_main".equals(temp[0])) { SchoolService schoolService = new SchoolServiceImp(); //String sql = "select * from school"; List<School> schools = schoolService.findSchoolRankListByYear(38,"2011"); this.getRequest().setAttribute("schools", schools); initLeft(); if("tEngSchool".equals(temp[0])) { this.getRequest().setAttribute("school_label", "推荐英国大学"); } else if("tEngSchool_main".equals(temp[0])) { this.getRequest().setAttribute("school_label", "推荐院校"); } this.getRequest().setAttribute("pathUrl", temp[0]); forward = "t-engSchool"; } else if("engCollege".equals(temp[0])) { SchoolService schoolService = new SchoolServiceImp(); String sql = "select * from school "; //List<School> schools = schoolService.findSchoolRankList(38,-1,-1,2); List<School> schools = schoolService.findSchoolBySql("select * from school s where s.type = 2 "); this.getRequest().setAttribute("schools", schools); initLeft(); this.getRequest().setAttribute("school_label", "英国学院"); this.getRequest().setAttribute("pathUrl", temp[0]); forward = "engCollege"; } else if("tEngCollege".equals(temp[0])) { SchoolService schoolService = new SchoolServiceImp(); //String sql = "select * from school"; //List<School> schools = schoolService.findSchoolRankList(38,-1,1,2); List<School> schools = schoolService.findSchoolBySql("select * from school s where s.type = 2 and s.recom = 1 "); this.getRequest().setAttribute("schools", schools); initLeft(); this.getRequest().setAttribute("school_label", "推荐英国学院"); this.getRequest().setAttribute("pathUrl", temp[0]); forward = "t-engCollege"; } else if("engMidSchool".equals(temp[0])) { SchoolService schoolService = new SchoolServiceImp(); String sql = "select * from school "; //List<School> schools = schoolService.findSchoolRankList(38,-1,-1,2); List<School> schools = schoolService.findSchoolBySql("select * from school s where s.type = 3 "); this.getRequest().setAttribute("schools", schools); initLeft(); this.getRequest().setAttribute("school_label", "英国中学"); this.getRequest().setAttribute("pathUrl", temp[0]); forward = "engMidSchool"; } else if("tEngMidSchool".equals(temp[0])) { SchoolService schoolService = new SchoolServiceImp(); //String sql = "select * from school"; //List<School> schools = schoolService.findSchoolRankList(38,-1,1,2); List<School> schools = schoolService.findSchoolBySql("select * from school s where s.type = 3 and s.recom = 1 "); this.getRequest().setAttribute("schools", schools); initLeft(); this.getRequest().setAttribute("school_label", "推荐英国中学"); this.getRequest().setAttribute("pathUrl", temp[0]); forward = "t-engMidSchool"; } } else if (temp.length == 2) { if("show".equals(temp[0])) { SchoolService schoolService = new SchoolServiceImp(); School school = schoolService.findSchoolById(temp[1]); this.getRequest().setAttribute("school", school); School_rank s = schoolService.getSchool_rank(2011, temp[1], "38"); this.getRequest().setAttribute("s", s); initLeft(); forward = "show"; } else if("engSchoolNews".equals(temp[0])) { NewsService newsService = new NewsServiceImp(); String sql = "select * from news n where n.smallId = "+temp[1]+" "; List<News> schoolNews = newsService.findMainListBySql(sql); this.getRequest().setAttribute("schoolNews", schoolNews); Smallclass small = newsService.findBySmallId(temp[1]); this.getRequest().setAttribute("small", small); initLeft(); forward = "engSchoolNews"; } else if("tEngSchoolNews".equals(temp[0])) { NewsService newsService = new NewsServiceImp(); String sql = "select * from news n where n.smallId = "+temp[1]+" and hot = 1 "; List<News> schoolNews = newsService.findMainListBySql(sql); this.getRequest().setAttribute("schoolNews", schoolNews); Smallclass small = newsService.findBySmallId(temp[1]); if(small!=null) small.setName("推荐"+small.getName()); this.getRequest().setAttribute("small", small); initLeft(); forward = "t-engSchoolNews"; } } } return forward; } private void initLeft() { //********************* NewsService newsService = new NewsServiceImp(); SchoolService schoolService = new SchoolServiceImp(); String sql; //客户评价 Smallclass small1Title = newsService.findBySmallId(String.valueOf(25)); this.getRequest().setAttribute("small1Title", small1Title); sql = "select * from news where smallId=25 order by sort1 desc,id desc limit 1"; News leftNews1 = newsService.findMainObjBySql(sql); this.getRequest().setAttribute("leftNews1", leftNews1); sql = "select* from news where smallId=25 order by sort1 desc,id desc limit 5"; List<News> leftNewsList1 = newsService.findMainListBySql(sql); this.getRequest().setAttribute("leftNewsList1", leftNewsList1); //校方点评 Smallclass small2Title = newsService.findBySmallId(String.valueOf(26)); this.getRequest().setAttribute("small2Title", small2Title); sql = "select * from news where smallId=26 order by sort1 desc,id desc limit 1"; News leftNews2 = newsService.findMainObjBySql(sql); this.getRequest().setAttribute("leftNews2", leftNews2); sql = "select * from news where smallId=26 order by sort1 desc,id desc limit 5"; List<News> leftNewsList2 = newsService.findMainListBySql(sql); this.getRequest().setAttribute("leftNewsList2", leftNewsList2); //推荐大学 //sql = "select * from news where bigId=2 and smallId=7 and hot=1 order by sort1 desc,id desc limit 10"; //List<News> leftNewsList3 = newsService.findMainListBySql(sql); //this.getRequest().setAttribute("leftNewsList3", leftNewsList3); sql = "select * from school s where s.recom = 1 limit 10"; List<School> leftSchoolsList = schoolService.findSchoolBySql(sql); this.getRequest().setAttribute("leftSchoolsList", leftSchoolsList); //推荐学院 sql = "select * from school s where s.recom = 1 and s.type = 2 limit 10"; List<School> leftSchoolsList3 = schoolService.findSchoolBySql(sql); this.getRequest().setAttribute("leftSchoolsList3", leftSchoolsList3); //推荐中学 //sql = "select * from news where bigId=2 and smallId=9 and hot=1 order by sort1 desc,id desc limit 10"; //List<News> leftNewsList5 = newsService.findMainListBySql(sql); //this.getRequest().setAttribute("leftNewsList5", leftNewsList5); sql = "select * from school s where s.recom = 1 and s.type = 3 limit 10"; List<School> leftSchoolsList4 = schoolService.findSchoolBySql(sql); this.getRequest().setAttribute("leftSchoolsList4", leftSchoolsList4); //院校快递 Smallclass small9Title = newsService.findBySmallId(String.valueOf(23)); this.getRequest().setAttribute("small9Title", small9Title); sql = "select * from news where smallId=23 and hot = 1 order by sort1 desc limit 3"; List<News> rightNewsList1 = newsService.findMainListBySql(sql); this.getRequest().setAttribute("rightNewsList1", rightNewsList1); //院校申请 Bigclass bigTitle2 = newsService.findBybigId(String.valueOf(7)); this.getRequest().setAttribute("bigTitle2", bigTitle2); sql = "select * from news where bigId=7 and hot = 1 order by sort1 desc limit 3"; List<News> rightNewsList2 = newsService.findMainListBySql(sql); this.getRequest().setAttribute("rightNewsList2", rightNewsList2); //热点话题 sql = "select * from news order by click desc,id desc limit 8 "; List<News> rightNewsList3 = newsService.findMainListBySql(sql); this.getRequest().setAttribute("rightNewsList3", rightNewsList3); //******************** } @Override public void validate() { // TODO Auto-generated method stub } public String getPath() { return path; } public void setPath(String path) { this.path = path; } }