最近把JavaWeb相关的东西学习的差不多了,跟着做了一个黑马旅游网的项目,
历时了五六天,终于做的差不多了,现在做一个总结一下这个项目。
GitHub链接:https://github.com/Ren8iaoXie/project-travel

--------------------------------------------------------------------------------------------


-----------------------------------------------------------------------------------------------
	用了maven管理项目,其中的jar包依赖全部在pom.xml中
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>cn.itcast</groupId>
  <artifactId>travel</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <!--servlet-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>


        <!--mysql驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.26</version>
            <scope>compile</scope>
        </dependency>
        <!--druid连接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.9</version>
        </dependency>
        <!--jdbcTemplate-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>4.1.2.RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>4.1.2.RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>4.1.2.RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>4.1.2.RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
            <scope>compile</scope>
        </dependency>
        <!--beanUtils-->
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.2</version>
            <scope>compile</scope>
        </dependency>
        <!--jackson-->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.3.3</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.3.3</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.3.3</version>
        </dependency>


        <!--javaMail-->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>javax.mail-api</artifactId>
            <version>1.5.6</version>
        </dependency>
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
            <version>1.5.3</version>
        </dependency>
        <!--jedis-->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.7.0</version>
        </dependency>

    </dependencies>


    <build>
        <!--maven插件-->
        <plugins>
            <!--jdk编译插件-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>utf-8</encoding>
                </configuration>
            </plugin>
            <!--tomcat插件-->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <!-- tomcat7的插件, 不同tomcat版本这个也不一样 -->
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <!-- 通过maven tomcat7:run运行项目时,访问项目的端口号 -->
                    <port>80</port>
                    <!-- 项目访问路径  本例:localhost:9090,  如果配置的aa, 则访问路径为localhost:9090/aa-->
                    <path>/travel</path>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>
-------------------------------------------------------------------------------------------------

总目录
在这里插入图片描述
src下的目录,java存放源文件,resources存放静态资源文件,webapp用来存放网页资源
在这里插入图片描述
在这里插入图片描述
利用了经典的三层架构,其中
dao包存放数据层类和对应的实现类
在这里插入图片描述

domain存放实体类

service包存放数据层类和对应的实现类
             CategoryService:分页类业务层            FavoriteService:收藏业务层              RouteService:路线业务层             UserService:用户业务层
util包存放工具类
在这里插入图片描述
web包放相关拦截器和servlet
在这里插入图片描述
两个properties都是用来给utils加载文件,travel是sql数据库,存放所有信息
在这里插入图片描述
在这里插入图片描述
webapp下的网页资源
在这里插入图片描述
配置好相关以后
在这里插入图片描述
走一遍流程
启动好tomcat后浏览器输入http://localhost/travel/index.html进入首页

在这里插入图片描述
点击注册
填好相关信息,其中,用户名和密码用了正则表达式限制需要8-20位,不然会报红
在这里插入图片描述
输入正确后取消报红
在这里插入图片描述
故意输入验证码错误
在这里插入图片描述
如果用户名重复会提示已存在
注册成功后
在这里插入图片描述
此时数据库状态为N
在这里插入图片描述
进入邮箱后点击链接激活
在这里插入图片描述
在这里插入图片描述
点击登录跳转到登陆页面
输入完信息进入点击国内游,因为数据库中只有国内游信息
在这里插入图片描述

有分页栏
在这里插入图片描述
会根据页码自动变换
在这里插入图片描述
搜索西安
在这里插入图片描述
有关西安的相关信息都出来了
点击查看详情进入详情页面在这里插入图片描述
标题和相关图片和信息价格等都会自动根据路线的rid查询数据库显示出来
点击 点击收藏
在这里插入图片描述
表示已收藏

总结:此案例因为用的是html展示页面,所以大部分都用ajax异步交互,在后台处理完数据封装回json格式再发送到前台再处理,后台的代码逻辑比较简单,主要是前台的处理json数据较为繁琐,很容易出错误,需要经常找错误,所以一定要理好逻辑清晰,就好做了。

2021-06-01 已经工作了比较繁忙,源码放在github上了,自取:https://github.com/Ren8iaoXie/project-travel

Logo

助力广东及东莞地区开发者,代码托管、在线学习与竞赛、技术交流与分享、资源共享、职业发展,成为松山湖开发者首选的工作与学习平台

更多推荐