失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 基于javaweb的旅游管理系统(java+jsp+html5+bootstrap+servlet+mysql)

基于javaweb的旅游管理系统(java+jsp+html5+bootstrap+servlet+mysql)

时间:2019-05-10 22:21:02

相关推荐

基于javaweb的旅游管理系统(java+jsp+html5+bootstrap+servlet+mysql)

基于javaweb的旅游管理系统(java+jsp+html5+bootstrap+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的旅游管理系统(java+JSP+HTML5+Bootstrap+servlet+Mysql)

项目介绍

本项目分为前台与后台,前台为游客浏览,后台为管理员管理;

管理员角色包含以下功能: 管理员登录,管留言信息修改,景点管理,资讯管理,图片库管理,留言管理,管理员管理等功能。

用户角色包含以下功能: 用户首页,景点介绍,人文地理,地区资讯,留言等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:否;

技术栈

HTML5+Ajax+CSS+JavaScript+BootStrap+jQuery+servlet+mysql

使用说明

使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中util/db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,前台运行地址输入http://localhost:8080/travel 登录 后台运行地址输入http://localhost:8080/travel/admin 登录 管理员账号/密码:admin/admin

登陆后台管理控制层:

/**

登陆后台管理界面

*/

@Controller

@RequestMapping(“/backgroundweb”)

public class SysloginController {

public Logger logger = LoggerFactory

.getLogger(SysloginController.class);// 输出日志

@Autowired

private SceneInformationService sceneInformationService;

@Autowired

private StrategyInfoemationService strategyInfoemationService;

@Autowired

private TourismUserService tourismUserService;

@Autowired

private SearchRecordService searchRecordService;

@RequestMapping(“/checkLogin”)

@ResponseBody

public JSONObject checkLogin(HttpServletRequest request,HttpServletResponse response,String userName,String passWord){

logger.info(“收到的用户名为:”+userName+“,密码为:”+passWord);

JSONObject json=new JSONObject();

if(userName.equals(“admin”) && passWord.equals(“123456”)){

request.getSession().setAttribute(“userName”,“admin”);

json.put(“fiag”, true);

}else{

json.put(“fiag”, false);

return json;

@RequestMapping(“/jumpMain”)

public String jumpMain(ModelMap model){

model.put(“userName”,“admin”);

return “backgroundWeb/main”;

//跳转新建景点界面

@RequestMapping(“/addAttractions”)

public String addAttractions(){

return “backgroundWeb/addAttractions”;

//跳转用户信息界面

@RequestMapping(“/viewUser”)

public String viewUser(){

return “backgroundWeb/viewUser”;

/**

用户退出

@return

*/

@RequestMapping(value=“/logout”)

public String dropOut(HttpServletRequest request, HttpServletResponse response){

HttpSession session = request.getSession();

session.removeAttribute(“userName”);

return “redirect:/login”;

//保存景点信息

@RequestMapping(“/save”)

@ResponseBody

public JSONObject save (@RequestBody AttractionsDto attractionsDto){

JSONObject json =new JSONObject();

boolean flag=true;

logger.info(“保存的实体类信息:”+JSONObject.toJSONString(attractionsDto));

try{

SceneInformation sceneInformation =new SceneInformation();

sceneInformation.setCreateTime(new Date());

sceneInformation.setState(1);

sceneInformation.setSceneSite(attractionsDto.getSceneSite());

sceneInformation.setSceneImage(attractionsDto.getSceneImage());

sceneInformation.setSceneName(attractionsDto.getSceneName());

sceneInformation.setScenePrice(attractionsDto.getScenePrice());

sceneInformation.setSceneTime(attractionsDto.getSceneTime());

sceneInformation.setSceneIntroduce(attractionsDto.getSceneIntroduce());

Integer aa= sceneInformationService.insert(sceneInformation);

logger.info(“返回的id为:”+aa+“当前实体类id为:”+sceneInformation.getId());

if(aa >0){

if(StringUtils.isNotEmpty(attractionsDto.getOneSite())){

StrategyInfoemation strategyInfoemation =new StrategyInfoemation();

strategyInfoemation.setStatus(Constant.isUsd);

strategyInfoemation.setCreateTime(new Date());

strategyInfoemation.setStrategyAccommodation(attractionsDto.getOneAccommodation());

strategyInfoemation.setStrategyDays(1);

strategyInfoemation.setStrategyIntroduce(attractionsDto.getOneIntroduce());

strategyInfoemation.setStrategySite(attractionsDto.getOneSite());

strategyInfoemation.setStrategyTraffic(attractionsDto.getOneTraffic());

strategyInfoemation.setSceneId(sceneInformation.getId());

strategyInfoemationService.insert(strategyInfoemation);

strategyInfoemation=null;

if(StringUtils.isNotEmpty(attractionsDto.getTwoSite())){

StrategyInfoemation twoStrategyInfoemation=new StrategyInfoemation();

twoStrategyInfoemation.setStatus(Constant.isUsd);

twoStrategyInfoemation.setCreateTime(new Date());

twoStrategyInfoemation.setStrategyAccommodation(attractionsDto.getTwoAccommodation());

twoStrategyInfoemation.setStrategyDays(2);

twoStrategyInfoemation.setSceneId(sceneInformation.getId());

twoStrategyInfoemation.setStrategyIntroduce(attractionsDto.getTwoIntroduce());

twoStrategyInfoemation.setStrategySite(attractionsDto.getTwoSite());

twoStrategyInfoemation.setStrategyTraffic(attractionsDto.getTwoTraffic());

strategyInfoemationService.insert(twoStrategyInfoemation);

twoStrategyInfoemation=null;

if(StringUtils.isNotEmpty(attractionsDto.getThreeSite())){

StrategyInfoemation threeStrategyInfoemation=new StrategyInfoemation();

threeStrategyInfoemation.setStatus(Constant.isUsd);

threeStrategyInfoemation.setCreateTime(new Date());

threeStrategyInfoemation.setStrategyAccommodation(attractionsDto.getThreeAccommodation());

threeStrategyInfoemation.setStrategyDays(3);

threeStrategyInfoemation.setSceneId(sceneInformation.getId());

threeStrategyInfoemation.setStrategyIntroduce(attractionsDto.getThreeIntroduce());

threeStrategyInfoemation.setStrategySite(attractionsDto.getThreeSite());

threeStrategyInfoemation.setStrategyTraffic(attractionsDto.getThreeTraffic());

strategyInfoemationService.insert(threeStrategyInfoemation);

threeStrategyInfoemation=null;

}else{

flag=false;

}catch(Throwable te){

flag=false;

logger.error(“保存景点信息异常信息为:”, te);

json.put(“flag”, flag);

return json;

@RequestMapping(“/selectUserAll”)

@ResponseBody

public PageBean selectUserAll(@RequestBody UserDto userDto){

PageBean pageBean = new PageBean();// 初始化分页的实体

try {

List list=tourismUserService.selectAllUsers(userDto.getRows(),userDto.getOffset(),userDto.getMobilePhone(),userDto.getUserName());

Integer count=tourismUserService.selectUserCount(userDto.getMobilePhone(),userDto.getUserName());

pageBean.setRows(list);

pageBean.setTotal(count);

}catch (Throwable te) {

logger.error(“查询用户所有信息异常信息为:”, te);

return pageBean;

@RequestMapping(“/viewSearchRecord”)

public String viewSearchRecord(){

return “backgroundWeb/viewSearchRecord”;

@RequestMapping(“/selectSearchRecordAll”)

@ResponseBody

public PageBean selectSearchRecordAll(@RequestBody SearchRecordDto searchRecordDto){

PageBean pageBean = new PageBean();// 初始化分页的实体

try {

List list=searchRecordService.selectAllSearchRecord(searchRecordDto.getRows(),searchRecordDto.getOffset(),searchRecordDto.getSearchScene(),searchRecordDto.getUserName());

Integer count=searchRecordService.selectSearchRecordCount(searchRecordDto.getSearchScene(),searchRecordDto.getUserName());

pageBean.setRows(list);

pageBean.setTotal(count);

}catch (Throwable te) {

logger.error(“查询搜索所有信息异常信息为:”, te);

return pageBean;

旅游网用户管理控制层:

/**

旅游网用户表 前端控制器

*/

@Controller

@RequestMapping(“/tourismUser”)

public class TourismUserController {

public Logger logger = LoggerFactory

.getLogger(TourismUserController.class);// 输出日志

@Autowired

private TourismUserService tourismUserService;

@RequestMapping(“/save”)

@ResponseBody

public ResponseInformation save(@RequestBody TourismUser tourismUser){

// 初始化返回码和返回信息,默认处理成功

ResponseInformation responseInformation=new ResponseInformation();

logger.info(“保存用户信息为:”+JSONObject.toJSONString(tourismUser));

try {

tourismUser.setCreateTime(new Date());

tourismUser.setStatus(Constant.isUsd);

Integer count= tourismUserService.insert(tourismUser);

if (count > 0) {

logger.info(“保存成功”);

}else{

responseInformation.setReponseCode(Constant.dataCode);

responseInformation.setReponseMessage(“数据异常”);

}catch(Throwable te){

responseInformation.setReponseCode(Constant.dataCode);

responseInformation.setReponseMessage(“保存失败”);

logger.error(“保存人员异常信息为:”, te);

return responseInformation;

@RequestMapping(“/checkLogin”)

@ResponseBody

public JSONObject checkLogin(HttpServletRequest request,HttpServletResponse response,String userName,String passWord){

logger.info(“收到的用户名为:”+userName+“,密码为:”+passWord);

JSONObject json=new JSONObject();

TourismUser tourismUser =new TourismUser();

tourismUser.setStatus(Constant.isUsd);

tourismUser.setUserArount(userName);

tourismUser.setUserPassword(passWord);

TourismUser retTourismUser = tourismUserService.selectOne(tourismUser);

if(null != retTourismUser){

request.getSession().setAttribute(“tourismUser”,retTourismUser.getUserName());

json.put(“fiag”, true);

}else{

json.put(“fiag”, false);

return json;

@RequestMapping(“/validUserName”)

@ResponseBody

public JSONObject validUserName(String userName){

JSONObject json=new JSONObject();

TourismUser TourismUser=new TourismUser();

TourismUser.setUserArount(userName);

TourismUser ret =tourismUserService.selectOne(TourismUser);

if(null != ret){

json.put(“flag”, false);

}else{

json.put(“flag”, true);

return json;

@RequestMapping(“/update”)

@ResponseBody

public ResponseInformation update(@RequestBody TourismUser tourismUser){

// 初始化返回码和返回信息,默认处理成功

ResponseInformation responseInformation=new ResponseInformation();

logger.info(“保存用户信息为:”+JSONObject.toJSONString(tourismUser));

try {

tourismUser.setCreateTime(new Date());

tourismUser.setStatus(Constant.isUsd);

Integer count= tourismUserService.updateById(tourismUser);

if (count > 0) {

logger.info(“保存成功”);

}else{

responseInformation.setReponseCode(Constant.dataCode);

responseInformation.setReponseMessage(“数据异常”);

}catch(Throwable te){

responseInformation.setReponseCode(Constant.dataCode);

responseInformation.setReponseMessage(“保存失败”);

logger.error(“保存人员异常信息为:”, te);

return responseInformation;

评论收藏管理控制层:

@Controller

@RequestMapping(“/tourismWeb”)

public class TourismWebController {

public Logger logger = LoggerFactory

.getLogger(TourismWebController.class);// 输出日志

@Autowired

private SceneInformationService sceneInformationService;

@Autowired

private SceneCommentsService sceneCommentsService;

@Autowired

private TourismUserService tourismUserService;

@Autowired

private SceneCollectionService sceneCollectionService;

@Autowired

private StrategyInfoemationService strategyInfoemationService;

@Autowired

private SearchRecordService searchRecordService;

@RequestMapping(“/selectSceneAll”)

@ResponseBody

public List selectSceneAll(HttpServletRequest request,HttpServletResponse response,String sceneName){

List list=new ArrayList();

if(StringUtils.isNotEmpty(sceneName)){

Map<String, Object> map=new HashMap<String, Object>();

map.put(“scene_name”,sceneName);

list=sceneInformationService.selectByMap(map);

}else{

list= sceneInformationService.selectByMap(null);

return list;

@RequestMapping(“/selectSceneDetail”)

public String selectSceneDetail(ModelMap map,String id){

SceneInformation sceneInformation = sceneInformationService.selectById(id);

map.put(“sceneInformation”,sceneInformation);

return “tourismWeb/senceDetail”;

@RequestMapping(“/selectSceneCommentsAll”)

@ResponseBody

public JSONObject selectSceneCommentsAll(String id){

StringBuffer sb = new StringBuffer();

JSONObject json=new JSONObject();

Map<String, Object> map=new HashMap<>();

map.put(“scene_id”,id);

List list=sceneCommentsService.selectByMap(map);

if(null != list && list.size() >0){

for(int i=0;i<list.size();i++){

sb.append(“评论人:”+list.get(i).getCommentsName());

sb.append(" ");

sb.append(“内容:”+list.get(i).getCommentsContent());

sb.append(" ");

sb.append(“时间:”+DateUtil.getStrDate(list.get(i).getCreateTime()));

sb.append(“\r\n”);

}else{

sb.append(“暂无”);

sb.append(“\r\n”);

json.put(“sb”, sb);

return json;

@RequestMapping(“/savecomments”)

@ResponseBody

public JSONObject savecomments(HttpServletRequest request,HttpServletResponse response,String commentsContent,String sceneId){

SceneComments sceneComments =new SceneComments();

JSONObject json=new JSONObject();

boolean flag=true;

String userName=“”;

try{

sceneComments.setCreateTime(new Date());

if(null != request.getSession()){

if(null != request.getSession().getAttribute(“tourismUser”)){

userName=request.getSession().getAttribute(“tourismUser”).toString();

sceneComments.setCommentsName(userName);

sceneComments.setCommentsContent(commentsContent);

sceneComments.setSceneId(Integer.parseInt(sceneId));

Integer count=sceneCommentsService.insert(sceneComments);

if(count >0){

logger.info(“保存评论成功”);

}else{

flag =false;

}catch(Throwable te){

flag =false;

logger.error(“保存评论异常信息为:”,te);

json.put(“flag”, flag);

json.put(“id”, sceneId);

return json;

@RequestMapping(“/jumpMayLike”)

public String jumpMayLike(){

return “tourismWeb/maylike”;

@RequestMapping(“/saveSeceneCollection”)

@ResponseBody

public JSONObject saveSeceneCollection(HttpServletRequest request,HttpServletResponse response,String sceneId){

JSONObject json=new JSONObject();

boolean flag=true;

String userName = “”;

SceneCollection sceneCollection =new SceneCollection();

try{

if(null != request.getSession()){

if(null != request.getSession().getAttribute(“tourismUser”)){

userName=request.getSession().getAttribute(“tourismUser”).toString();

TourismUser tourismUser =new TourismUser();

tourismUser.setUserName(userName);

TourismUser retTourismUser= tourismUserService.selectOne(tourismUser);

if(null != retTourismUser){

sceneCollection.setUserId(retTourismUser.getId());

sceneCollection.setUserName(retTourismUser.getUserName());

SceneInformation retSceneInformation=sceneInformationService.selectById(sceneId);

if(null != retSceneInformation){

sceneCollection.setSceneId(retSceneInformation.getId());

sceneCollection.setSceneName(retSceneInformation.getSceneName());

sceneCollection.setCreateTime(new Date());

sceneCollection.setStatus(Constant.isUsd);

Integer count= sceneCollectionService.insert(sceneCollection);

if(count >0){

logger.info(“收藏成功”);

}else{

flag=false;

}catch(Throwable te){

flag=false;

te.printStackTrace();

json.put(“flag”, flag);

return json;

@RequestMapping(“/selectMayLikeScene”)

@ResponseBody

public JSONObject selectMayLikeScene(HttpServletRequest request,HttpServletResponse response){

String userName=“”;

JSONObject json =new JSONObject();

List list=new ArrayList();

try{

if(null != request.getSession()){

if(null != request.getSession().getAttribute(“tourismUser”)){

userName=request.getSession().getAttribute(“tourismUser”).toString();

TourismUser tourismUser =new TourismUser();

tourismUser.setUserName(userName);

TourismUser retTourismUser= tourismUserService.selectOne(tourismUser);

if(null != retTourismUser){

SceneInformation sceneInformation =new SceneInformation();

sceneInformation.setSceneName(retTourismUser.getWantScene());

SceneInformation retSceneInformation=sceneInformationService.selectOne(sceneInformation);

if(null != retSceneInformation){

list.add(retSceneInformation);

Map<String, Object> map=new HashMap<>();

map.put(“user_name”,userName);

List searchRecordList= searchRecordService.selectByMap(map);

if(null != searchRecordList){

for(int i=0;i<searchRecordList.size();i++){

if(null !=searchRecordList.get(i).getSceneId()){

SceneInformation ret=sceneInformationService.selectById(searchRecordList.get(i).getSceneId());

list.add(ret);

}catch(Throwable te){

te.printStackTrace();

json.put(“list”, list);

return json;

@RequestMapping(“/jumpTourismPlan”)

public String jumpTourismPlan(){

return “tourismWeb/tourismPlan”;

@RequestMapping(“/selectSeceneCollection”)

@ResponseBody

public JSONObject selectSeceneCollection(HttpServletRequest request,HttpServletResponse response){

String userName=“”;

Random random = new Random();

JSONObject json=new JSONObject();

try{

if(null != request.getSession()){

if(null != request.getSession().getAttribute(“tourismUser”)){

userName=request.getSession().getAttribute(“tourismUser”).toString();

Map<String, Object> map=new HashMap<>();

Map<String, Object> strategyInfoemationMap=new HashMap<>();

map.put(“user_name”, userName);

List list=sceneCollectionService.selectByMap(map);

if(null != list && list.size() >0){

SceneCollection sceneCollection =list.get(random.nextInt(list.size()));

if(null != sceneCollection){

SceneInformation sceneInformation =sceneInformationService.selectById(sceneCollection.getSceneId());

json.put(“sceneInformation”, sceneInformation);

strategyInfoemationMap.put(“scene_id”, sceneCollection.getSceneId());

List strategyInfoemation =strategyInfoemationService.selectByMap(strategyInfoemationMap);

json.put(“strategyInfoemation”,strategyInfoemation);

}else{

json.put(“sceneInformation”,null);

json.put(“strategyInfoemation”, null);

}else{

json.put(“sceneInformation”,null);

json.put(“strategyInfoemation”, null);

}catch(Throwable te){

te.printStackTrace();

return json;

@RequestMapping(“/updateSeceneCollection”)

@ResponseBody

public JSONObject updateSeceneCollection(@RequestBody SaveSceneCollectionDto saveSceneCollectionDto){

JSONObject json =new JSONObject();

boolean falg=true;

try{

if(StringUtils.isNotEmpty(saveSceneCollectionDto.getSceneId())){

Map<String, Object> map=new HashMap<>();

map.put(“scene_id”, saveSceneCollectionDto.getSceneId());

Integer count= strategyInfoemationService.deleteByMap(map);

if(count >0){

if(null !=saveSceneCollectionDto.getSceneCollectionList() && saveSceneCollectionDto.getSceneCollectionList().size() >0){

for(int i=0;i<saveSceneCollectionDto.getSceneCollectionList().size();i++){

StrategyInfoemation strategyInfoemation=saveSceneCollectionDto.getSceneCollectionList().get(i);

strategyInfoemation.setSceneId(Integer.parseInt(saveSceneCollectionDto.getSceneId()));

strategyInfoemation.setCreateTime(new Date());

strategyInfoemation.setStatus(Constant.isUsd);

strategyInfoemationService.insert(strategyInfoemation);

}else{

falg=false;

}catch(Throwable te){

falg=false;

te.printStackTrace();

json.put(“flag”, falg);

return json;

@RequestMapping(“/editUser”)

public String editUser(){

return “tourismWeb/editUser”;

@RequestMapping(“/selectUserInformation”)

@ResponseBody

public JSONObject selectUserInformation(HttpServletRequest request,HttpServletResponse response){

String userName=“”;

JSONObject json=new JSONObject();

if(null != request.getSession()){

if(null != request.getSession().getAttribute(“tourismUser”)){

userName=request.getSession().getAttribute(“tourismUser”).toString();

TourismUser TourismUser=new TourismUser();

TourismUser.setUserName(userName);

TourismUser ret =tourismUserService.selectOne(TourismUser);

json.put(“ret”, ret);

return json;

如果觉得《基于javaweb的旅游管理系统(java+jsp+html5+bootstrap+servlet+mysql)》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。