Design and Implementation of Tourist Attraction Line Booking System Based on Javaweb

1 Introduction

With the continuous improvement of people's living standards in our country, tourism has gradually become the first choice for people to relax and adjust their emotions after work. In recent years, the scale of tourists in my country has continued to expand, which has led to the rapid development of tourism, but it has also brought more intense competition. Faced with more complex tourism business needs, the tourism industry must now expand the promotion of local tourism resources, use more advanced technology to complete daily management, provide better services for tourists, and help

It helps tourists quickly and conveniently inquire about the scenic spots, hotels, and traffic conditions of the tourist destination when they travel. This will improve the city's tourism image and tourism service level. Therefore, the establishment of an information system that integrates and manages tourism information resources can strengthen the internal management of the local tourism industry, make the operation more reasonable and efficient, and improve the service quality of tourism.

The rapid development of computer and network technology has popularized its application in all walks of life in society. More and more industries use advanced computing network technology to manage industry information. Human society has entered a new era of informatization. At present, the process of informatization in my country's tourism industry is slow, and most of the traditional urban tourism publicity and management methods are done manually, resulting in a waste of human and material resources. The development and use of the tourism information management system can take advantage of the advantages of information technology to free the staff from the tedious manual work, improve the management efficiency of tourism information, and realize the communication between tourists and tourism staff in a convenient and timely manner. It is convenient for managers and travel agencies to understand the needs of tourists in a timely and accurate manner, and provide higher-quality services, which can enable tourist cities and scenic spots to gain advantages in fierce competition, expand publicity efforts, and improve publicity effects.

This paper designs and develops a set of information management system for tourism resources based on the service integration and information integration requirements of tourism management. Firstly, it describes the development background of the tourism information management system and the current situation of tourism informationization at home and abroad; then it introduces the technology and related tools used in the system development; secondly, it analyzes the needs of the system's users, system administrators and tourists; Carried out the overall design of the system again, through the classification of tourism information resources, the functional modules in the system are divided according to the specific content of the information involved in tourism, and the detailed design of each functional module is carried out. The main modules of the system background include: user management, homepage, tourist attractions, travel routes, hotel accommodation, tongue-in-cheek food, travel guides, travel help groups, etc., and developed background functions such as management and release of travel-related information by system administrators. In the foreground of the system, tourists and registered users are provided with the browsing function of tourism-related information, and hotel and line reservation functions are realized for registered users. When the system is implemented, the three-tier B/S architecture is used for development, the development tools based on the Java platform are applied, and mysql is used as the background database management platform for system development. And after the system development is completed, the main modules of the system are tested. The test results show that the system designed and developed in this paper can meet the needs of users. The application of this system will strengthen the internal management of urban tourism, improve work efficiency and service quality.

2. Development technology

2.1B/S Architecture

B/S structure (Browser/Server, that is, browser/server structure) is a common software architecture pattern for building web applications. In the B/S structure, the browser acts as a client, sends a request to the server, and displays the result returned by the server.

The following are several key components and descriptions of the B/S structure:

(1) Client (browser): The client interacts with the user through the browser, sends a request to the server, and displays the result returned by the server to the user. The browser is responsible for parsing and rendering webpage resources such as HTML, CSS, and JavaScript, and presenting them to users for browsing.

(2) Server (application server): The server receives requests from clients and generates responses based on the content of the requests. It is responsible for handling business logic, interacting with backend databases, generating dynamic pages and data, etc. Servers usually use programming languages ​​and frameworks (such as Java and Spring, Python and Django, etc.) to process requests.

(3) Database server: The database server is used to store and manage application data. The server can obtain, modify and store data by accessing the database. The database usually uses a relational database system such as MySQL, Oracle or a non-relational database system such as MongoDB.

(4) Network communication: B/S structure communicates through the network. The client sends the request to the server through the HTTP protocol, and the server returns the result to the client through the HTTP response. This HTTP-based communication makes the B/S structure cross-platform and cross-network.

In the B/S structure, the client only needs a browser and does not need to install complex applications. This makes deployment and maintenance of the application relatively simple. In addition, by using web technologies such as HTML, CSS, and JavaScript, rich user interfaces and interactive effects can be achieved.

All in all, the B/S structure is a software architecture pattern based on browsers and servers, which is suitable for building web applications. By simplifying client deployment and dependencies, the B/S structure provides a flexible, cross-platform way to develop and deliver applications.

2.2 MVC mode

MVC (Model-View-Controller) is a common software design pattern used to separate application concerns and logic. It decomposes the application into three main components: model (Model), view (View) and controller (Controller), each component has its specific responsibilities and functions.

The following is the function and description of each component in the MVC pattern:

(1) Model (Model): The model represents the data and business logic of the application. It is responsible for acquiring, saving, and processing data, and provides methods and operations related to data. The model is not concerned with how the data is presented or interacted with by the user, it is only concerned with the management and processing of the data.

(2) View (View): The view is the user interface of the application, and the data in the model is displayed. Views are responsible for displaying and presenting data to the user, as well as receiving user input. It is usually implemented by technologies such as HTML, CSS, and Graphical User Interface (GUI) to display data in a visual way.

(3)控制器(Controller):控制器协调模型和视图之间的交互,并处理用户的输入和操作。它接收来自用户界面的输入,根据需要调用模型进行数据处理,并将处理结果传递给视图进行显示。控制器还负责处理应用程序的业务逻辑,如验证和处理用户输入、路由请求等。

MVC模式的优点包括:

  • 分离关注点:MVC模式将应用程序分解成不同的组件,使其职责和关注点分离。这样可以提高代码的可维护性、可重用性和可测试性。

  • 可扩展性:每个组件都有其特定的职责,使得应用程序更容易升级和扩展。例如,可以更改视图的实现方式而不影响模型和控制器,或者添加新的控制器来处理新的业务逻辑。

  • 多个视图:MVC模式可以支持多个视图,使得相同的数据可以以不同的方式呈现给用户。这样可以实现多平台或多设备的支持,提供更好的用户体验。

MVC模式在各种应用程序中得到广泛应用,特别是Web应用程序和桌面应用程序。它提供了一种结构化和可维护的方式来组织和管理应用程序的逻辑和用户界面。

2.3Java Web开发技术

Java Web开发涉及多种技术和框架,用于构建功能强大、可扩展和安全的Web应用程序。以下是一些常用的Java Web开发技术:

(1)Java Servlet:Java Servlet是用于处理HTTP请求和响应的Java编程接口。它可以接收和响应请求,处理业务逻辑,并生成动态网页内容。Servlet通常作为Java Web应用程序的控制器来处理用户请求。

(2)Java Server Pages(JSP):JSP是一种动态网页技术,允许将Java代码嵌入到HTML模板中。JSP在服务器端执行,当客户端请求访问时,动态生成HTML页面并将其发送到客户端。

(3)JavaServer Faces(JSF):JSF是一种Java Web应用程序框架,用于构建用户界面。它提供了一套丰富的标签库和组件,用于创建交互式的用户界面,并支持事件驱动的编程模型。

(4)Spring MVC:Spring MVC是Spring框架的一部分,用于构建基于模型-视图-控制器(MVC)设计模式的Web应用程序。它提供了一个灵活和可扩展的框架,用于处理用户请求、渲染视图和管理业务逻辑。

(5)Hibernate:Hibernate是一个Java持久化框架,用于将对象映射到关系型数据库中。它提供了对象关系映射(ORM)功能,隐藏了底层数据库操作的复杂性,简化了数据访问层的开发。

(6)Spring Boot:Spring Boot是一个用于快速构建Spring应用程序的框架。它简化了Spring的配置和部署,提供了一系列的自动化配置,使得开发人员能够更专注于业务逻辑的开发。

(7)RESTful Web服务:REST(Representational State Transfer)是一种用于构建可伸缩和可维护的Web服务的架构风格。Java提供了多个技术和框架,如JAX-RS和Spring Web等,用于构建RESTful Web服务。

总的来说,Java Web开发技术提供了丰富的工具和框架,用于开发高性能、安全可靠的Web应用程序。通过使用Java Servlet、JSP、Spring MVC、Hibernate等技术,开发人员可以创建功能强大的Web应用程序,并实现与数据库的交互、用户界面的构建和业务逻辑的处理。

3.功能设计

在概要设计时,要按照前面所完成的系统需求分析的结果和文档信息,定义系统的主要功能模块。在本次设计的系统中,功能分为前台展示和后台管理两大部分,即景点信息的后台维护和前台检索;旅游路线的后台维护和前台展示检索;酒店信息的后台维护及前台检索、预订。

本节对系统部分功能模块的结构再进一步细化。

(1)用户信息管理模块

用户信息管理模块分为后台管理员信息的维护模块和前台注册用户的维护模块,并提供对各类用户的权限分配功能。

用户信息维护模块又分为注册用户信息维护和管理员信息维护子功能。注册用户信息维护可完成对前台系统注册的游客信息的检索和操纵处理功能,而管理员信息维护可在后台进行管理员的添加、以及后续的修改、删除等维护功能,而其中对用户信息的修改,一般是指对用户密码的修改。

(2)旅游景点信息维护模块

系统中的旅游景点信息维护可以对本地景点信息进行维护,可在前台实现景点信息的检索和浏览,在后台具有:景点信息查询、景点信息添加、景点信息修改和删除功能。景点信息检索或查询:可以按本地景点的名称或景点所属类型查询目标景点,也可以列出本地全部的景点。当选中某一景点后,可查看该景点的介绍,包括地理位置、到达的公交车的信息等。景点信息添加:可增加新的景点的相关信息,录入信息包括:景点的名称、位置、介绍、特点、可达公交车等。

景点信息修改:当选中某一个已经录入的景点后,可打开修改页面,对该景点信息进行修改,除景点名称外,其他信息均可进行修改。

景点信息删除:删除选中的景点信息,可删除一个景点,也可同时选中的多个景点。

旅游景点信息维护模块的应用意义在于当管理在进行旅游景点信息维护时,能够快捷地将景点信息添加到系统中,同时对景点的相关信息进行维护,并与后点的旅游信息数据库连接,将景点信息及时存放到旅游信息数据库中。而访问前台系统的用户能对后台管理员所添加、更新的景点信息进行及时、方便地浏览。

(3)酒店信息维护模块

本维护模块实现本地主要酒店的信息维护功能。具体来说,包括当时酒店信息查询模块、酒店信息添加模块、酒店信息修改模块和酒店信息删除模块。在进行酒店信息查询时,可根据酒店的名称、级别进行查询,也可显示系统全部酒店信息,并可根据入住的酒店信息查询到就近的景点信息。

系统管理员可通过酒店信息添加模块向系统数据库增加新的酒店信息,在新增酒店信息时,需要维护该酒店的名称、级别、就近景点信息、所提供房型等相关信息。另外,系统还提供了对酒店信息进行修改和删除的功能。

4.实现效果展示

后台系统登录界面是系统管理员访问旅游信息管理系统,进行后台信息维护的入口,是保证为合法用户提供系统的有效访问,而防止用户的越权访问或非法用户的访问的有效手段。旅游信息管理后台系统的登录界面实现效果如图所示。

当用户输入正确的帐户和密码后,会进入后台系统,显示如图

系统主界面中菜单栏显示了后台系统的功能,在本文的旅游信息管理系统中,完成了用户管理、景点信息管理、线路信息管理、酒店信息管理几个主要功能,用户通过选择菜单项,可进入相应的系统功能界面。

用户管理

旅游线路管理及添加管理

 旅游线路分类管理

 出游方式管理

 景点管理

 酒店管理

线路预订管理

 酒店预订管理

 本节对旅游信息管理系统中前台系统的部分功能的实现效果进行介绍。

用户注册

 旅游景点页面

 旅游景点详细页面

旅游景点线路预订页面

5.参考文章

6.核心代码


@Controller
public class AdminUserController extends SimpleController {

	@Autowired
	private UsersService usersService;

	@Override
	@RequestMapping("/admin/login.do")
	public void mapping(HttpServletRequest request, HttpServletResponse response) {
		super.mappingMethod(request, response);

	}
	public void login() {
		String usertype = request.getParameter("usertype");
		String validcode = (String) request.getSession().getAttribute(
				"validcode");
		String inputvalidcode = request.getParameter("validcode");
		if (validcode != null && !validcode.equals(inputvalidcode)) {
			System.out.println("系统验证错误");
			request.setAttribute("errmsg",
					"<img src=\"images/error.gif\"/>系统验证码错误");

			// 分发请求参数
			dispatchParams(request, response);
			forward("/admin/login.jsp");
			return;
		}
		System.out.println("验证码=" + validcode);
		if (usertype != null && usertype.equals("0")) {
			adminLogin();
		}
	}

	private void adminLogin() {

		String username = request.getParameter("username");
		String password = request.getParameter("password");
		Users u = (Users) usersService.load(" where username='" + username
				+ "' and password='" + password + "'");
		if (u == null) {
			dispatchParams(request, response);
			request.setAttribute("errmsg",
					"<img src=\"images/error.gif\"/>用户与密码不匹配");
			System.out.println("系统用户登录失败");
			forward("/admin/login.jsp");
		}
		HttpSession session = request.getSession();
		u.setLogtimes(u.getLogtimes() + 1);
		usersService.update(u);
		session.setAttribute("users", u);
		redirect("/admin/index.jsp");

	}

}
@Controller
public class AreacityController extends  SimpleController{
     @Autowired
       private AreacityService  areacitySrv=null;
       @Override
	@RequestMapping("/admin/areacitymanager.do")
	public void mapping(HttpServletRequest request, HttpServletResponse response) {
		mappingMethod(request,response);
	}
    /********************************************************
    ******************????????*****************************
    *********************************************************/
	public void delete() {
		String[] ids = request.getParameterValues("ids");
		if (ids == null)
			return;
		String spliter = ",";
		String SQL = " where id in(" + join(spliter, ids)
				+ ")";
		System.out.println("sql=" + SQL);
		areacitySrv.delete(SQL);
	}
    /*************************************************************
     ****************????????******************************
    **************************************************************/
	public void save() {
			String forwardurl=request.getParameter("forwardurl");
			//????url
			String errorurl=request.getParameter("errorurl");
				        String cityname=request.getParameter("cityname");
	    SimpleDateFormat  sdfareacity=new SimpleDateFormat("yyyy-MM-dd");
             Areacity areacity=new Areacity();
				        areacity.setCityname(cityname==null?"":cityname);
		    //????
		     Boolean validateresult=areacitySrv.isExist( "where cityname='"+cityname+"'");
		     if(validateresult){
			 try {
					request.setAttribute("errormsg","<label class='error'>??????</label>");
					request.setAttribute("areacity", areacity);
					request.setAttribute("actiontype", "save");
					request.getRequestDispatcher(errorurl).forward(request, response);
				} catch (Exception e) {
						e.printStackTrace();
				}
				return;
			}
		  areacitySrv.save(areacity);
		 if(forwardurl==null){
			forwardurl="/admin/areacitymanager.do?actiontype=get";
		}
		redirect(forwardurl);
	}
   	/******************************************************
	***********************??????*********************
	*******************************************************/
	public void update() {
           String forwardurl=request.getParameter("forwardurl");
		   String id=request.getParameter("id");
		   if(id==null)
			   return;
		   Areacity  areacity=areacitySrv.load(new Integer(id));
		    if(areacity==null)
			   return;
				       String cityname=request.getParameter("cityname");
			  SimpleDateFormat  sdfareacity=new SimpleDateFormat("yyyy-MM-dd");
					        areacity.setCityname(cityname);
		    areacitySrv.update(areacity);
			 if(forwardurl==null){
				forwardurl="/admin/areacitymanager.do?actiontype=get";
			}
			redirect(forwardurl);
	}
   	/******************************************************
	***********************??????*********************
	*******************************************************/
	public void load() {
	        //
		    String id=request.getParameter("id");
		    String actiontype="save";
		    dispatchParams(request, response);
			if(id!=null) 
			{
			   Areacity  areacity=areacitySrv.load("where id="+id);
				if(areacity!=null) 
				{
				    request.setAttribute("areacity", areacity);
				}
				actiontype="update";
				request.setAttribute("id", id);
			}
		    request.setAttribute("actiontype", actiontype);
		    String forwardurl=request.getParameter("forwardurl");
		    System.out.println("forwardurl="+forwardurl);
		    if(forwardurl==null){
		     	forwardurl="/admin/areacityadd.jsp";
		   }
		   forward(forwardurl);
	}
   	/******************************************************
	***********************????????*********************
	*******************************************************/
	public void   get(){
		 String filter="where 1=1 ";
String cityname=request.getParameter("cityname");
	              if(cityname!=null)
	                     filter+="  and cityname like '%"+cityname+"%'  ";
		 //
		int pageindex = 1;
		int pagesize = 10;
		// ??????
		String currentpageindex = request.getParameter("currentpageindex");
		// ??????
		String currentpagesize = request.getParameter("pagesize");
		// ?????
		if (currentpageindex != null)
			pageindex = new Integer(currentpageindex);
		// ???????
		if (currentpagesize != null)
			pagesize = new Integer(currentpagesize);
		List<Areacity> listareacity = areacitySrv.getPageEntitys( filter,pageindex, pagesize);
		int recordscount = areacitySrv.getRecordCount(filter == null ? "" : filter);
		request.setAttribute("listareacity", listareacity);
		PagerMetal pm = new PagerMetal(recordscount);
		//????
		pm.setPagesize(pagesize);
		//???????
		pm.setCurpageindex(pageindex);
		// ??????
		request.setAttribute("pagermetal", pm);
		//??????
		dispatchParams(request, response);
		String forwardurl=request.getParameter("forwardurl");
		System.out.println("forwardurl="+forwardurl);
		if(forwardurl==null){
			forwardurl="/admin/areacitymanager.jsp";
		}
forward(forwardurl);
	}
}
@Controller
public class CommentController extends SimpleController {

	@Autowired
	private CommentService commentSrv=null;
	@Override
	@RequestMapping("/admin/commentmanager.do")
	public void mapping(HttpServletRequest request, HttpServletResponse response) {
		mappingMethod(request,response);
	}
	
	/********************************************************
	 ****************** 信息注销监听支持*****************************
	 *********************************************************/
	public void delete() {
		String id = request.getParameter("id");
		commentSrv.delete(" where id=" + id);
		get();
	}

	/*************************************************************
	 **************** 保存动作监听支持******************************
	 **************************************************************/
	public void save() {
		String photo = request.getParameter("photo");

		String commentren = request.getParameter("currenthy");
		String commentcontent = request.getParameter("commentcontent");
		String xtype = request.getParameter("xtype");
		String belongid = request.getParameter("belongid");
		String istopic=request.getParameter("istopic");
	    String topicid=request.getParameter("topicid");
		Comment comment = new Comment();
		comment.setPhoto(photo);
		comment.setCommenttime(new Date());

		comment.setCommentren(commentren == null ? "" : commentren);
		comment.setCommentcontent(commentcontent == null ? "" : commentcontent);
		comment.setXtype(xtype == null ? "" : xtype);
		comment.setBelongid(belongid == null ? "" : belongid);
		
		if(istopic!=null)
        	comment.setTopicid(new Integer(topicid));
        else 
        	comment.setTopicid(0);
        if(topicid!=null)
        	comment.setIstopic(new Integer(istopic));
        else
        	comment.setTopicid(0);
		commentSrv.save(comment);

		String forwardurl = request.getParameter("forwardurl");
		redirect(forwardurl);

	}

	

	/******************************************************
	 *********************** 加载内部支持*********************
	 *******************************************************/
	public void load() {
		//
		String id = request.getParameter("id");
		String actiontype = "save";
		if (id != null) {
			Comment comment = commentSrv.load( "where id="+ id);
			if (comment != null) {
				request.setAttribute("comment", comment);
			}
			actiontype = "update";
		}
		request.setAttribute("id", id);
		request.setAttribute("actiontype", actiontype);
		try {
			request.getRequestDispatcher("commentadd.jsp").forward(request,
					response);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/******************************************************
	 *********************** 数据绑定内部支持*********************
	 *******************************************************/
	public void get() {
		String filter = "";
		//
		String commentren = request.getParameter("commentren");
		if (commentren != null)
			filter = "  where commentren like '%" + commentren + "%'  ";
		int pageindex = 1;
		int pagesize = 10;
		// 获取当前分页
		String currentpageindex = request.getParameter("currentpageindex");
		// 当前页面尺寸
		String currentpagesize = request.getParameter("pagesize");
		// 设置当前页
		if (currentpageindex != null)
			pageindex = new Integer(currentpageindex);
		// 设置当前页尺寸
		if (currentpagesize != null)
			pagesize = new Integer(currentpagesize);
		List<Comment> listcomment = commentSrv.getPageEntitys(filter,pageindex, pagesize);
		int recordscount =  commentSrv.getRecordCount(filter == null ? "" : filter);
		request.setAttribute("listcomment", listcomment);
		PagerMetal pm = new PagerMetal(recordscount);
		// 设置尺寸
		pm.setPagesize(pagesize);
		// 设置当前显示页
		pm.setCurpageindex(pageindex);
		// 设置分页信息
		request.setAttribute("pagermetal", pm);
		// 分发请求参数
		dispatchParams(request, response);
		try {
			request.getRequestDispatcher("/admin/commentmanager.jsp").forward(
					request, response);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
@Controller
public class CommentController extends SimpleController {

	@Autowired
	private CommentService commentSrv=null;
	@Override
	@RequestMapping("/admin/commentmanager.do")
	public void mapping(HttpServletRequest request, HttpServletResponse response) {
		mappingMethod(request,response);
	}
	
	/********************************************************
	 ****************** 信息注销监听支持*****************************
	 *********************************************************/
	public void delete() {
		String id = request.getParameter("id");
		commentSrv.delete(" where id=" + id);
		get();
	}

	/*************************************************************
	 **************** 保存动作监听支持******************************
	 **************************************************************/
	public void save() {
		String photo = request.getParameter("photo");

		String commentren = request.getParameter("currenthy");
		String commentcontent = request.getParameter("commentcontent");
		String xtype = request.getParameter("xtype");
		String belongid = request.getParameter("belongid");
		String istopic=request.getParameter("istopic");
	    String topicid=request.getParameter("topicid");
		Comment comment = new Comment();
		comment.setPhoto(photo);
		comment.setCommenttime(new Date());

		comment.setCommentren(commentren == null ? "" : commentren);
		comment.setCommentcontent(commentcontent == null ? "" : commentcontent);
		comment.setXtype(xtype == null ? "" : xtype);
		comment.setBelongid(belongid == null ? "" : belongid);
		
		if(istopic!=null)
        	comment.setTopicid(new Integer(topicid));
        else 
        	comment.setTopicid(0);
        if(topicid!=null)
        	comment.setIstopic(new Integer(istopic));
        else
        	comment.setTopicid(0);
		commentSrv.save(comment);

		String forwardurl = request.getParameter("forwardurl");
		redirect(forwardurl);

	}

	

	/******************************************************
	 *********************** 加载内部支持*********************
	 *******************************************************/
	public void load() {
		//
		String id = request.getParameter("id");
		String actiontype = "save";
		if (id != null) {
			Comment comment = commentSrv.load( "where id="+ id);
			if (comment != null) {
				request.setAttribute("comment", comment);
			}
			actiontype = "update";
		}
		request.setAttribute("id", id);
		request.setAttribute("actiontype", actiontype);
		try {
			request.getRequestDispatcher("commentadd.jsp").forward(request,
					response);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/******************************************************
	 *********************** 数据绑定内部支持*********************
	 *******************************************************/
	public void get() {
		String filter = "";
		//
		String commentren = request.getParameter("commentren");
		if (commentren != null)
			filter = "  where commentren like '%" + commentren + "%'  ";
		int pageindex = 1;
		int pagesize = 10;
		// 获取当前分页
		String currentpageindex = request.getParameter("currentpageindex");
		// 当前页面尺寸
		String currentpagesize = request.getParameter("pagesize");
		// 设置当前页
		if (currentpageindex != null)
			pageindex = new Integer(currentpageindex);
		// 设置当前页尺寸
		if (currentpagesize != null)
			pagesize = new Integer(currentpagesize);
		List<Comment> listcomment = commentSrv.getPageEntitys(filter,pageindex, pagesize);
		int recordscount =  commentSrv.getRecordCount(filter == null ? "" : filter);
		request.setAttribute("listcomment", listcomment);
		PagerMetal pm = new PagerMetal(recordscount);
		// 设置尺寸
		pm.setPagesize(pagesize);
		// 设置当前显示页
		pm.setCurpageindex(pageindex);
		// 设置分页信息
		request.setAttribute("pagermetal", pm);
		// 分发请求参数
		dispatchParams(request, response);
		try {
			request.getRequestDispatcher("/admin/commentmanager.jsp").forward(
					request, response);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
@Controller
public class CystyleController extends  SimpleController{
     @Autowired
       private CystyleService  cystyleSrv=null;
       @Override
	@RequestMapping("/admin/cystylemanager.do")
	public void mapping(HttpServletRequest request, HttpServletResponse response) {
		mappingMethod(request,response);
	}
    /********************************************************
    ******************????????*****************************
    *********************************************************/
	public void delete() {
		String[] ids = request.getParameterValues("ids");
		if (ids == null)
			return;
		String spliter = ",";
		String SQL = " where id in(" + join(spliter, ids)
				+ ")";
		System.out.println("sql=" + SQL);
		cystyleSrv.delete(SQL);
	}
    /*************************************************************
     ****************????????******************************
    **************************************************************/
	public void save() {
			String forwardurl=request.getParameter("forwardurl");
			//????url
			String errorurl=request.getParameter("errorurl");
				        String name=request.getParameter("name");
	    SimpleDateFormat  sdfcystyle=new SimpleDateFormat("yyyy-MM-dd");
             Cystyle cystyle=new Cystyle();
				        cystyle.setName(name==null?"":name);
		    //????
		     Boolean validateresult=cystyleSrv.isExist( "where name='"+name+"'");
		     if(validateresult){
			 try {
					request.setAttribute("errormsg","<label class='error'>????????</label>");
					request.setAttribute("cystyle", cystyle);
					request.setAttribute("actiontype", "save");
					request.getRequestDispatcher(errorurl).forward(request, response);
				} catch (Exception e) {
						e.printStackTrace();
				}
				return;
			}
		  cystyleSrv.save(cystyle);
		 if(forwardurl==null){
			forwardurl="/admin/cystylemanager.do?actiontype=get";
		}
		redirect(forwardurl);
	}
   	/******************************************************
	***********************??????*********************
	*******************************************************/
	public void update() {
           String forwardurl=request.getParameter("forwardurl");
		   String id=request.getParameter("id");
		   if(id==null)
			   return;
		   Cystyle  cystyle=cystyleSrv.load(new Integer(id));
		    if(cystyle==null)
			   return;
				       String name=request.getParameter("name");
			  SimpleDateFormat  sdfcystyle=new SimpleDateFormat("yyyy-MM-dd");
					        cystyle.setName(name);
		    cystyleSrv.update(cystyle);
			 if(forwardurl==null){
				forwardurl="/admin/cystylemanager.do?actiontype=get";
			}
			redirect(forwardurl);
	}
   	/******************************************************
	***********************??????*********************
	*******************************************************/
	public void load() {
	        //
		    String id=request.getParameter("id");
		    String actiontype="save";
		    dispatchParams(request, response);
			if(id!=null) 
			{
			   Cystyle  cystyle=cystyleSrv.load("where id="+id);
				if(cystyle!=null) 
				{
				    request.setAttribute("cystyle", cystyle);
				}
				actiontype="update";
				request.setAttribute("id", id);
			}
		    request.setAttribute("actiontype", actiontype);
		    String forwardurl=request.getParameter("forwardurl");
		    System.out.println("forwardurl="+forwardurl);
		    if(forwardurl==null){
		     	forwardurl="/admin/cystyleadd.jsp";
		   }
		   forward(forwardurl);
	}
   	/******************************************************
	***********************????????*********************
	*******************************************************/
	public void   get(){
		 String filter="where 1=1 ";
String name=request.getParameter("name");
	              if(name!=null)
	                     filter+="  and name like '%"+name+"%'  ";
		 //
		int pageindex = 1;
		int pagesize = 10;
		// ??????
		String currentpageindex = request.getParameter("currentpageindex");
		// ??????
		String currentpagesize = request.getParameter("pagesize");
		// ?????
		if (currentpageindex != null)
			pageindex = new Integer(currentpageindex);
		// ???????
		if (currentpagesize != null)
			pagesize = new Integer(currentpagesize);
		List<Cystyle> listcystyle = cystyleSrv.getPageEntitys( filter,pageindex, pagesize);
		int recordscount = cystyleSrv.getRecordCount(filter == null ? "" : filter);
		request.setAttribute("listcystyle", listcystyle);
		PagerMetal pm = new PagerMetal(recordscount);
		//????
		pm.setPagesize(pagesize);
		//???????
		pm.setCurpageindex(pageindex);
		// ??????
		request.setAttribute("pagermetal", pm);
		//??????
		dispatchParams(request, response);
		String forwardurl=request.getParameter("forwardurl");
		System.out.println("forwardurl="+forwardurl);
		if(forwardurl==null){
			forwardurl="/admin/cystylemanager.jsp";
		}
forward(forwardurl);
	}
}
@Controller
public class IndexcolumnsController extends SimpleController {

	@Autowired
	private IndexcolumnsService icSrv=null;
	@Autowired
	private LanmuService lanmuSrv=null;
	@Override
	@RequestMapping("/admin/indexcolumnsmanager.do")
	public void mapping(HttpServletRequest request, HttpServletResponse response) {
		mappingMethod(request,response);
	}
	/********************************************************
	 ****************** 信息注销监听支持*****************************
	 *********************************************************/
	public void delete() {
		String[] ids = request.getParameterValues("ids");
		if (ids == null)
			return;
		String spliter = ",";
		String SQL = " delete from indexcolumns  where id in(" + join(spliter, ids)
				+ ")";
		System.out.println("sql=" + SQL);
		Adapter adapter=new MybatisAdapter("applicationContext.xml", "sqlSessionFactoryBean");
		SimpleJdbc dapper=new SimpleJdbc(adapter);
		try {
			dapper.update(SQL);
		} catch (SQLException e) {

			e.printStackTrace();
		}

	}



	/*************************************************************
	 **************** 保存动作监听支持******************************
	 **************************************************************/
	public void save() {

		String forwardurl = request.getParameter("forwardurl");
		// 验证错误url
		String suzuid=request.getParameter("suzuid");
		String errorurl = request.getParameter("errorurl");

		String xtype=request.getParameter("xtype");
		if(suzuid!=null)
		{
			Lanmu temspc=lanmuSrv.load("where id="+suzuid);
			if(temspc!=null&&xtype!=null&&xtype.equals("1"))
			{
				Indexcolumns indexcolumns = new Indexcolumns();
				indexcolumns.setColdes(temspc.getTitle());
				indexcolumns.setColid(temspc.getId());
				indexcolumns.setXtype("资讯");
				indexcolumns.setShowstyle("图片");
				indexcolumns.setLayout("1");
				indexcolumns.setWidth("100%");

				icSrv.save(indexcolumns);
			}
		}
		if (forwardurl == null) {
			forwardurl = "/admin/indexcolumnsmanager.do?actiontype=get";
		}
		redirect(forwardurl);
	}


	/******************************************************
	 *********************** 更新内部支持*********************
	 *******************************************************/
	public void update() {
		String forwardurl = request.getParameter("forwardurl");
		String id = request.getParameter("id");
		if (id == null)
			return;
		Indexcolumns indexcolumns = icSrv.load(new Integer(id));
		if (indexcolumns == null)
			return;
		String coldes = request.getParameter("coldes");
		String colid = request.getParameter("colid");
		String xtype = request.getParameter("xtype");
		String showstyle = request.getParameter("showstyle");
		String layout=request.getParameter("layout");
		String width=request.getParameter("width");

		indexcolumns.setColdes(coldes);
		indexcolumns.setColid(colid == null ? 0 : new Integer(colid));
		indexcolumns.setXtype(xtype);
		indexcolumns.setShowstyle(showstyle);
		indexcolumns.setLayout(layout);
		indexcolumns.setWidth(width);
		icSrv.update(indexcolumns);

		if (forwardurl == null) {
			forwardurl = "/admin/indexcolumnsmanager.do?actiontype=get";
		}
		redirect(forwardurl);
	}

	/******************************************************
	 *********************** 加载内部支持*********************
	 *******************************************************/
	public void load() {
		//
		String id = request.getParameter("id");
		String actiontype = "save";
		dispatchParams(request, response);
		if (id != null) {
			Indexcolumns indexcolumns = (Indexcolumns) icSrv.load("where id=" + id);
			if (indexcolumns != null) {
				request.setAttribute("indexcolumns", indexcolumns);
			}
			actiontype = "update";
			request.setAttribute("id", id);
		}
		request.setAttribute("actiontype", actiontype);
		String forwardurl = request.getParameter("forwardurl");
		System.out.println("forwardurl=" + forwardurl);
		if (forwardurl == null) {
			forwardurl = "/admin/indexcolumnsadd.jsp";
		}
		try {
			request.getRequestDispatcher(forwardurl).forward(request, response);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/******************************************************
	 *********************** 数据绑定内部支持*********************
	 *******************************************************/
	public void get() {
		String filter = "where 1=1 ";
		String coldes = request.getParameter("coldes");
		if (coldes != null)
			filter += "  and coldes like '%" + coldes + "%'  ";
		//
		int pageindex = 1;
		int pagesize = 10;
		// 获取当前分页
		String currentpageindex = request.getParameter("currentpageindex");
		// 当前页面尺寸
		String currentpagesize = request.getParameter("pagesize");
		// 设置当前页
		if (currentpageindex != null)
			pageindex = new Integer(currentpageindex);
		// 设置当前页尺寸
		if (currentpagesize != null)
			pagesize = new Integer(currentpagesize);
		List<Indexcolumns> listindexcolumns = icSrv.getPageEntitys(filter, pageindex, pagesize);
		int recordscount = icSrv.getRecordCount(filter == null ? "" : filter);
		request.setAttribute("listindexcolumns", listindexcolumns);
		PagerMetal pm = new PagerMetal(recordscount);
		// 设置尺寸
		pm.setPagesize(pagesize);
		// 设置当前显示页
		pm.setCurpageindex(pageindex);
		// 设置分页信息
		request.setAttribute("pagermetal", pm);
		// 分发请求参数
		dispatchParams(request, response);
		String forwardurl = request.getParameter("forwardurl");
		System.out.println("forwardurl=" + forwardurl);
		if (forwardurl == null) {
			forwardurl = "/admin/indexcolumnsmanager.jsp";
		}
		try {
			request.getRequestDispatcher(forwardurl).forward(request, response);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}

Guess you like

Origin blog.csdn.net/lf21qp/article/details/131710352