尚硅谷大数据技术之电信客服

2) 创建包结构,根包:com.atguigu

表13

bean

 

 

contants

 

 

controller

 

 

dao

 

 

entries

 

 

3) 类表

表14

类名

备注

CallLog

用于封装数据分析结果的JavaBean

Contact

用于封装联系人的JavaBean

Contants

常量类

CallLogHandler

用于处理请求的Controller

CallLogDAO

查询某人某个维度通话记录的DAO

ContactDAO

查询联系人的DAO

QueryInfo

用于封装向服务器发来的请求参数

4) web目录结构,web部分的根目录:webapp

 

表15

文件夹名

备注

css

存放css静态资源的文件夹

html

存放html静态资源的文件夹

images

存放图片静态资源文件夹

js

存放js静态资源的文件夹

jsp

存放jsp页面的文件夹

WEB-INF

存放web相关配置的文件夹

5) resources目录下创建spring相关配置文件

dbconfig.properties:用于存放数据库连接配置

user=root

password=000000

jdbcUrl=jdbc:mysql://hadoop102:3306/db_telecom?useUnicode=true&characterEncoding=UTF-8

driverClass=com.mysql.jdbc.Driver

applicationContext.xmlSpring&SpringMVC配置

<?xml version=”1.0″ encoding=”UTF-8″?>

<beans xmlns=”http://www.springframework.org/schema/beans”

       xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”

       xmlns:p=”http://www.springframework.org/schema/p”

       xmlns:mvc=”http://www.springframework.org/schema/mvc”

       xmlns:context=”http://www.springframework.org/schema/context”

       xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd

        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd

        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd

        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd

        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd”>

    <context:property-placeholder location=”classpath:dbconfig.properties”/>

 

    <bean id=”dataSource” class=”com.mchange.v2.c3p0.ComboPooledDataSource”>

        <property name=”user” value=”${user}”/>

        <property name=”password” value=”${password}”/>

        <property name=”driverClass” value=”${driverClass}”/>

        <property name=”jdbcUrl” value=”${jdbcUrl}”/>

    </bean>

    <bean id=”jdbcTemplate” class=”org.springframework.jdbc.core.JdbcTemplate”>

        <constructor-arg name=”dataSource” value=”#{dataSource}”></constructor-arg>

    </bean>

 

    <bean id=”namedParameterJdbcTemplate” class=”org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate”>

        <constructor-arg name=”dataSource” value=”#{dataSource}”></constructor-arg>

    </bean>

    <!– 包扫描 –>

    <context:component-scan base-package=”com.atguigu.controller”></context:component-scan>

    <context:component-scan base-package=”com.atguigu.dao”></context:component-scan>

    <!– 配置视图解析器–>

    <bean id=”viewResolver” class=”org.springframework.web.servlet.view.InternalResourceViewResolver”>

        <property name=”prefix” value=”/”/>

        <property name=”suffix” value=”.jsp”/>

    </bean>

 

    <!–<mvc:annotation-driven />–>

    <!–<mvc:default-servlet-handler />–>

    <!–<mvc:resources location=”/images/” mapping=”/images/**”/>–>

    <!–<mvc:resources location=”/js/” mapping=”/js/**”/>–>

    <!–<mvc:resources location=”/css/” mapping=”/css/**”/>–>

</beans>

6) WEB-INF目录下创建web相关配置

web.xml

<?xml version=”1.0″ encoding=”UTF-8″?>

<web-app xmlns=”http://xmlns.jcp.org/xml/ns/javaee”

         xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”

         xsi:schemaLocation=”http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd”

         version=”3.1″>

    <display-name>SpringMVC_CRUD</display-name>

    <servlet>

        <servlet-name>dispatcherServlet</servlet-name>

        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

        <init-param>

            <param-name>contextConfigLocation</param-name>

            <param-value>classpath:applicationContext.xml</param-value>

        </init-param>

        <load-on-startup>1</load-on-startup>

    </servlet>

    <servlet-mapping>

        <servlet-name>dispatcherServlet</servlet-name>

        <url-pattern>/</url-pattern>

    </servlet-mapping>

    <welcome-file-list>

        <welcome-file>index.jsp</welcome-file>

    </welcome-file-list>

    <filter>

        <filter-name>CharacterEncodingFilter</filter-name>

        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>

        <init-param>

            <param-name>encoding</param-name>

            <param-value>utf-8</param-value>

        </init-param>

        <init-param>

            <param-name>forceEncoding</param-name>

            <param-value>true</param-value>

        </init-param>

    </filter>

    <filter-mapping>

        <filter-name>CharacterEncodingFilter</filter-name>

        <url-pattern>/*</url-pattern>

    </filter-mapping>

 

    <servlet-mapping>

        <servlet-name>default</servlet-name>

        <url-pattern>*.jpg</url-pattern>

    </servlet-mapping>

    <servlet-mapping>

        <servlet-name>default</servlet-name>

        <url-pattern>*.js</url-pattern>

    </servlet-mapping>

    <servlet-mapping>

        <servlet-name>default</servlet-name>

        <url-pattern>*.css</url-pattern>

    </servlet-mapping>

</web-app>

 

 

 


上一篇:
下一篇:
关于尚硅谷
教育理念
名师团队
学员心声
资源下载
视频下载
资料下载
工具下载
加入我们
招聘岗位
岗位介绍
招贤纳师
联系我们
全国统一咨询电话:010-56253825
地址:北京市昌平区宏福科技园综合楼6层(北京校区)

深圳市宝安区西部硅谷大厦B座C区一层(深圳校区)

上海市松江区谷阳北路166号大江商厦6层(上海校区)

武汉市东湖高新开发区东湖网谷(武汉校区)