SSM+angularJS框架基本配置

1.brand.HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>品牌管理</title>
<meta
	content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
	name="viewport">
<link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="../plugins/adminLTE/css/AdminLTE.css">
<link rel="stylesheet"
	href="../plugins/adminLTE/css/skins/_all-skins.min.css">
<link rel="stylesheet" href="../css/style.css">
<script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="../plugins/bootstrap/js/bootstrap.min.js"></script>
<!-- 导入angularjs -->
<script type="text/javascript" src="angular.min.js"></script>
<!-- 分页组件开始 -->
<script type="text/javascript" src="../plugins/angularjs/pagination.js"></script>
<link rel="stylesheet" href="../plugins/angularjs/pagination.css">
<!-- 分页组件结束 -->

<!-- 导入分离后的js文件 -->
<script type="text/javascript" src="../js/base_pagination.js"></script>
<script type="text/javascript" src="../js/service/brandService.js"></script>
<script type="text/javascript" src="../js/controller/baseController.js"></script>
<script type="text/javascript" src="../js/controller/brandController.js"></script>


</head>
<body class="hold-transition skin-red sidebar-mini" ng-app="pinyougou"
	ng-controller="brandController">
	<!-- .box-body -->
	<div class="box-header with-border">
		<h3 class="box-title">品牌管理</h3>
	</div>

	<div class="box-body">

		<!-- 数据表格 -->
		<div class="table-box">

			<!--工具栏-->
			<div class="pull-left">
				<div class="form-group form-inline">
					<div class="btn-group">
						<button type="button" class="btn btn-default" title="新建"
							data-toggle="modal" data-target="#editModal" ng-click="entity={}">
							<i class="fa fa-file-o"></i> 新建
						</button>
						<button type="button" class="btn btn-default" title="删除"
							ng-click="dele()">
							<i class="fa fa-trash-o"></i> 删除
						</button>
						<button type="button" class="btn btn-default" title="刷新"
							onclick="window.location.reload();">
							<i class="fa fa-refresh"></i> 刷新
						</button>
					</div>
				</div>
			</div>
			<div class="box-tools pull-right">
				<div class="has-feedback"></div>
				品牌名称:<input ng-model="searchEntity.name">品牌首字母:<input
					ng-model="searchEntity.firstChar">
				<button class="btn btn-default" ng-click="reloadList()">查询</button>
			</div>
			<!--工具栏/-->

			<!--数据列表-->
			<table id="dataList"
				class="table table-bordered table-striped table-hover dataTable">
				<thead>
					<tr>
						<th class="" style="padding-right: 0px"><input id="selall"
							type="checkbox" class="icheckbox_square-blue"></th>
						<th class="sorting_asc">品牌ID</th>
						<th class="sorting">品牌名称</th>
						<th class="sorting">品牌首字母</th>
						<th class="text-center">操作</th>
					</tr>
				</thead>
				<tbody>
					<tr ng-repeat="entity in list">
						<td><input type="checkbox"
							ng-click="updateSelection($event,entity.id)"></td>
						<td>{{entity.id}}</td>
						<td>{{entity.name}}</td>
						<td>{{entity.firstChar}}</td>
						<td class="text-center">
							<button type="button" class="btn bg-olive btn-xs"
								data-toggle="modal" data-target="#editModal"
								ng-click="findOne(entity.id)">修改</button>
						</td>
					</tr>

				</tbody>
			</table>
			<!--数据列表/-->
			<!-- 分页控件 -->
			<tm-pagination conf="paginationConf"></tm-pagination>
		</div>
		<!-- 数据表格 /-->
	</div>
	<!-- /.box-body -->

	<!-- 编辑窗口 -->
	<div class="modal fade" id="editModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">×</button>
					<h3 id="myModalLabel">品牌编辑</h3>
				</div>
				<div class="modal-body">
					<table class="table table-bordered table-striped" width="800px">
						<tr>
							<td>品牌名称</td>
							<td><input class="form-control" placeholder="品牌名称"
								ng-model="entity.name"></td>
						</tr>
						<tr>
							<td>首字母</td>
							<td><input class="form-control" placeholder="首字母"
								ng-model="entity.firstChar"></td>
						</tr>
					</table>
				</div>
				<div class="modal-footer">
					<button class="btn btn-success" data-dismiss="modal"
						aria-hidden="true" ng-click="save()">保存</button>
					<button class="btn btn-default" data-dismiss="modal"
						aria-hidden="true">关闭</button>
				</div>
			</div>
		</div>
	</div>

</body>
</html>

2.brandController.js

//控制层
app.controller('brandController', function($scope, $controller, brandService) {// 创建控制器

	// 继承baseController
	$controller('baseController', {
		$scope : $scope
	});

	// 读取列表数据绑定到表单
	$scope.findAll = function() {
		brandService.findAll().success(function(data) {
			$scope.list = data;
		});
	}

	// 分页数据处理
	$scope.findPage = function(page, size) {
		brandService.findPage(page, size).success(function(data) {
			$scope.list = data.rows;// 显示当前这的数据
			$scope.paginationConf.totalItems = data.total;// 更新总记录数
		});
	}

	// 添加品牌
	$scope.save = function() {
		var object = null;// 方法名
		if ($scope.entity.id != null) {// 如果id不等于空(该品牌已存在)
			object = brandService.update($scope.entity);// 更新方法
		} else {
			object = brandService.add($scope.entity);// 添加方法
		}
		object.success(function(data) {
			if (data.success) {
				$scope.reloadList();// 成功则刷新列表
			} else {
				alert(data.massage);// 失败则弹出失败提示窗口
			}
		});
	}

	// 条件查询实体
	$scope.findOne = function(id) {
		brandService.findOne(id).success(function(data) {
			$scope.entity = data;
		});
	}

	// 批量删除
	$scope.dele = function() {
		// 获取选中的复选框
		brandService.dele($scope.selectIds).success(function(data) {
			if (data.success) {// 成功则刷新页面
				$scope.reloadList();// 调用方法,重新加载
			}
		});
	}
	// 初始化
	$scope.searchEntity = {};
	// 条件查询
	$scope.search = function(page, size) {
		brandService.search(page, size, $scope.searchEntity).success(
				function(data) {
					$scope.list = data.rows;// 显示当前这的数据
					$scope.paginationConf.totalItems = data.total;// 更新总记录数
				});
	}
	

});

3.brandService.js

//品牌服务层
app.service('brandService',
		function($http) {

			this.findAll = function() {
				return $http.get('../brand/findAll.do');
			}
			this.findPage = function(page, size) {
				return $http.get('../brand/findPage.do?page=' + page + '&size='
						+ size);
			}
			this.findOne = function(id) {
				return $http.get('../brand/findOne.do?id=' + id);
			}
			this.add = function(entity) {
				return $http.post('../brand/add.do', entity);
			}
			this.update = function(entity) {
				return $http.post('../brand/update.do', entity);
			}
			this.dele = function(selectIds) {
				return $http.get('../brand/delete.do?ids=' + selectIds);
			}
			this.search = function(page, size, searchEntity) {
				return $http.post('../brand/search.do?page=' + page + '&size='
						+ size, searchEntity);
			}
			// 下拉列表数据
			this.selectOptionList = function() {
				return $http.get('../brand/selectOptionList.do');
			}

		});

4.BrandController.java

package com.pinyougou.manager.controller;

import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.pinyougou.pojo.TbBrand;
import com.pinyougou.sellergoods.service.BrandService;

import entity.PageResult;
import entity.Result;

/**
 * 品牌的控制层
 * 
 * @author qinho
 *
 */
@RestController
@RequestMapping("/brand")
public class BrandController {
	/**
	 * 远程注入
	 */
	@Reference
	private BrandService brandService;

	/**
	 * 查询并返回全部品牌数据
	 * 
	 * @return
	 */
	@RequestMapping("/findAll")
	public List<TbBrand> findAll() {
		return brandService.findAll();
	}

	/**
	 * 分页返回品牌数据
	 * 
	 * @param page
	 * @param size
	 * @return
	 */
	@RequestMapping("/findPage")
	public PageResult findPage(int page, int size) {
		return brandService.findPage(page, size);
	}

	/**
	 * 添加品牌
	 * 
	 * @param brand
	 * @return
	 */
	@RequestMapping("/add")
	public Result add(@RequestBody TbBrand brand) {// 传递的参数是一个对象类型所以需要使用@RequstBody直接

		try {
			brandService.add(brand);
			return new Result(true, "添加成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false, "添加失败");
		}
	}

	/**
	 * 修改品牌
	 * 
	 * @param brand
	 * @return
	 */
	@RequestMapping("/update")
	public Result update(@RequestBody TbBrand brand) {// 传递的参数是一个对象类型所以需要使用@RequstBody直接
		try {
			brandService.update(brand);
			return new Result(true, "修改成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false, "修改失败");
		}
	}

	/**
	 * 通过id获取实体
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping("/findOne")
	public TbBrand findOne(long id) {
		return brandService.findOne(id);
	}

	/**
	 * 删除选中
	 * 
	 * @param ids
	 * @return
	 */
	@RequestMapping("/delete")
	public Result delete(Long[] ids) {
		try {
			brandService.delete(ids);
			return new Result(true, "删除成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false, "删除失败");
		}
	}

	/**
	 * 条件查询,分页返回品牌数据
	 * 
	 * @param page
	 * @param size
	 * @return
	 */
	@RequestMapping("/search")
	public PageResult search(@RequestBody TbBrand brand, int page, int size) {
		return brandService.findPage(brand, page, size);
	}

	/**
	 * 下拉列表
	 * 
	 * @return
	 */
	@RequestMapping("/selectOptionList")
	public List<Map> selectOptionList() {
		return brandService.selectOptionList();
	}

}

5.BrandService.Interface

package com.pinyougou.sellergoods.service;

import java.util.List;
import java.util.Map;

import com.pinyougou.pojo.TbBrand;

import entity.PageResult;

/**
 * 品牌接口
 * 
 * @author qinho
 *
 */
public interface BrandService {
	/**
	 * 品牌展示
	 * 
	 * @return
	 */
	List<TbBrand> findAll();

	/**
	 * 品牌的分页
	 * 
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	PageResult findPage(int pageNum, int pageSize);

	/**
	 * 添加品牌
	 * 
	 * @param brand
	 */
	void add(TbBrand brand);

	/**
	 * 更新品牌
	 * 
	 * @param brand
	 */
	void update(TbBrand brand);

	/**
	 * 根据id获取实体
	 * 
	 * @param id
	 * @return
	 */
	TbBrand findOne(long id);

	/**
	 * 删除选中
	 * 
	 * @param ids
	 */
	void delete(Long[] ids);

	/**
	 * 条件查询分页
	 * 
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	PageResult findPage(TbBrand brand, int pageNum, int pageSize);

	/**
	 * 品牌下拉框数据
	 */
	List<Map> selectOptionList();

}

6.BrandService.java

package com.pinyougou.sellergoods.service.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbBrandMapper;
import com.pinyougou.pojo.TbBrand;
import com.pinyougou.pojo.TbBrandExample;
import com.pinyougou.pojo.TbBrandExample.Criteria;
import com.pinyougou.sellergoods.service.BrandService;

import entity.PageResult;

/**
 * 品牌的实现类
 * 
 * @author qinho
 *
 */
@Service
public class BrandServiceImpl implements BrandService {
	@Autowired
	private TbBrandMapper brandMapper;

	/**
	 * 查询全部品牌数据
	 */
	public List<TbBrand> findAll() {
		// 查询全部品牌,不加条件
		return brandMapper.selectByExample(null);
	}

	/**
	 * 分页查询品牌数据
	 */
	public PageResult findPage(int pageNum, int pageSize) {
		// 调用分页插件的方法
		PageHelper.startPage(pageNum, pageSize);
		// 获取数据,强转数据类型
		Page<TbBrand> page = (Page<TbBrand>) brandMapper.selectByExample(null);
		// 取出所需数据存入自定义的PageResult类中进行返回
		return new PageResult(page.getTotal(), page.getResult());
	}

	/**
	 * 添加品牌
	 */
	public void add(TbBrand brand) {
		// 添加数据
		brandMapper.insert(brand);
	}

	/**
	 * 更新品牌
	 */
	public void update(TbBrand brand) {
		// 更新数据,通过主键id
		brandMapper.updateByPrimaryKey(brand);

	}

	/**
	 * 根据id获取实体
	 */
	public TbBrand findOne(long id) {
		// 查询数据,通过主键id
		return brandMapper.selectByPrimaryKey(id);
	}

	/**
	 * 删除选中
	 */
	@Override
	public void delete(Long[] ids) {
		// 创建example对象(执行条件)
		TbBrandExample example = new TbBrandExample();
		// 获取条件拼接对象
		Criteria criteria = example.createCriteria();
		// 将数组转换为集合
		List<Long> list = Arrays.asList(ids);
		// 拼接( id in ) 传递集合数据
		criteria.andIdIn(list);

		brandMapper.deleteByExample(example);

	}

	@Override
	public PageResult findPage(TbBrand brand, int pageNum, int pageSize) {
		// 创建example对象(执行条件)
		TbBrandExample example = new TbBrandExample();
		// 判断brand对象不为空
		if (brand != null) {
			// 获取条件拼接对象
			Criteria criteria = example.createCriteria();
			// 判断name属性不为空
			if (brand.getName() != null && brand.getName().length() > 0)
				// 拼接查询条件
				criteria.andNameLike("%" + brand.getName() + "%");
			// 判断firstChar属性不为空
			if (brand.getFirstChar() != null && brand.getFirstChar().length() > 0)
				// 拼接查询条件
				criteria.andFirstCharLike("%" + brand.getFirstChar() + "%");
		}
		// 调用分页插件的方法
		PageHelper.startPage(pageNum, pageSize);
		// 获取数据,强转数据类型
		Page<TbBrand> page = (Page<TbBrand>) brandMapper.selectByExample(example);
		// 取出所需数据存入自定义的PageResult类中进行返回
		return new PageResult(page.getTotal(), page.getResult());
	}

	@Override
	public List<Map> selectOptionList() {
		
		return brandMapper.selectOptionList();
	}

}

7.BrandMapper

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pinyougou.mapper.TbBrandMapper">
	<resultMap id="BaseResultMap" type="com.pinyougou.pojo.TbBrand">
		<id column="id" property="id" jdbcType="BIGINT" />
		<result column="name" property="name" jdbcType="VARCHAR" />
		<result column="first_char" property="firstChar" jdbcType="VARCHAR" />
	</resultMap>
	<sql id="Example_Where_Clause">
		<where>
			<foreach collection="oredCriteria" item="criteria" separator="or">
				<if test="criteria.valid">
					<trim prefix="(" suffix=")" prefixOverrides="and">
						<foreach collection="criteria.criteria" item="criterion">
							<choose>
								<when test="criterion.noValue"> 
									and ${criterion.condition}
								</when>
								<when test="criterion.singleValue">
									and ${criterion.condition} #{criterion.value}
								</when>
								<when test="criterion.betweenValue">
									and ${criterion.condition} #{criterion.value}
									and
									#{criterion.secondValue}
								</when>
								<when test="criterion.listValue">
									and ${criterion.condition}
									<foreach collection="criterion.value" item="listItem"
										open="(" close=")" separator=",">
										#{listItem}
									</foreach>
								</when>
							</choose>
						</foreach>
					</trim>
				</if>
			</foreach>
		</where>
	</sql>
	<sql id="Update_By_Example_Where_Clause">
		<where>
			<foreach collection="example.oredCriteria" item="criteria"
				separator="or">
				<if test="criteria.valid">
					<trim prefix="(" suffix=")" prefixOverrides="and">
						<foreach collection="criteria.criteria" item="criterion">
							<choose>
								<when test="criterion.noValue">
									and ${criterion.condition}
								</when>
								<when test="criterion.singleValue">
									and ${criterion.condition} #{criterion.value}
								</when>
								<when test="criterion.betweenValue">
									and ${criterion.condition} #{criterion.value}
									and
									#{criterion.secondValue}
								</when>
								<when test="criterion.listValue">
									and ${criterion.condition}
									<foreach collection="criterion.value" item="listItem"
										open="(" close=")" separator=",">
										#{listItem}
									</foreach>
								</when>
							</choose>
						</foreach>
					</trim>
				</if>
			</foreach>
		</where>
	</sql>
	<sql id="Base_Column_List">
		id, name, first_char
	</sql>
	<select id="selectByExample" resultMap="BaseResultMap"
		parameterType="com.pinyougou.pojo.TbBrandExample">
		select
		<if test="distinct">
			distinct
		</if>
		<include refid="Base_Column_List" />
		from tb_brand
		<if test="_parameter != null">
			<include refid="Example_Where_Clause" />
		</if>
		<if test="orderByClause != null">
			order by ${orderByClause}
		</if>
	</select>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap"
		parameterType="java.lang.Long">
		select
		<include refid="Base_Column_List" />
		from tb_brand
		where id = #{id,jdbcType=BIGINT}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
		delete from
		tb_brand
		where id = #{id,jdbcType=BIGINT}
	</delete>
	<delete id="deleteByExample" parameterType="com.pinyougou.pojo.TbBrandExample">
		delete from tb_brand
		<if test="_parameter != null">
			<include refid="Example_Where_Clause" />
		</if>
	</delete>
	<insert id="insert" parameterType="com.pinyougou.pojo.TbBrand">
		insert into tb_brand (id,
		name, first_char
		)
		values (#{id,jdbcType=BIGINT},
		#{name,jdbcType=VARCHAR},
		#{firstChar,jdbcType=VARCHAR}
		)
	</insert>
	<insert id="insertSelective" parameterType="com.pinyougou.pojo.TbBrand">
		insert into tb_brand
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="id != null">
				id,
			</if>
			<if test="name != null">
				name,
			</if>
			<if test="firstChar != null">
				first_char,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="id != null">
				#{id,jdbcType=BIGINT},
			</if>
			<if test="name != null">
				#{name,jdbcType=VARCHAR},
			</if>
			<if test="firstChar != null">
				#{firstChar,jdbcType=VARCHAR},
			</if>
		</trim>
	</insert>
	<select id="countByExample" parameterType="com.pinyougou.pojo.TbBrandExample"
		resultType="java.lang.Integer">
		select count(*) from tb_brand
		<if test="_parameter != null">
			<include refid="Example_Where_Clause" />
		</if>
	</select>
	<update id="updateByExampleSelective" parameterType="map">
		update tb_brand
		<set>
			<if test="record.id != null">
				id = #{record.id,jdbcType=BIGINT},
			</if>
			<if test="record.name != null">
				name = #{record.name,jdbcType=VARCHAR},
			</if>
			<if test="record.firstChar != null">
				first_char = #{record.firstChar,jdbcType=VARCHAR},
			</if>
		</set>
		<if test="_parameter != null">
			<include refid="Update_By_Example_Where_Clause" />
		</if>
	</update>
	<update id="updateByExample" parameterType="map">
		update tb_brand
		set id = #{record.id,jdbcType=BIGINT},
		name =
		#{record.name,jdbcType=VARCHAR},
		first_char =
		#{record.firstChar,jdbcType=VARCHAR}
		<if test="_parameter != null">
			<include refid="Update_By_Example_Where_Clause" />
		</if>
	</update>
	<update id="updateByPrimaryKeySelective" parameterType="com.pinyougou.pojo.TbBrand">
		update tb_brand
		<set>
			<if test="name != null">
				name = #{name,jdbcType=VARCHAR},
			</if>
			<if test="firstChar != null">
				first_char = #{firstChar,jdbcType=VARCHAR},
			</if>
		</set>
		where id = #{id,jdbcType=BIGINT}
	</update>
	<update id="updateByPrimaryKey" parameterType="com.pinyougou.pojo.TbBrand">
		update tb_brand
		set name = #{name,jdbcType=VARCHAR},
		first_char =
		#{firstChar,jdbcType=VARCHAR}
		where id = #{id,jdbcType=BIGINT}
	</update>

	<select id="selectOptionList" resultType="java.util.Map">
		select id,name as text from tb_brand
	</select>

</mapper>

8.controller.web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	version="2.5">	
   <!-- 解决post乱码 -->
	<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>
  	<servlet-name>springmvc</servlet-name>
  	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  	
  	
  	<!-- 指定加载的配置文件 ,通过参数contextConfigLocation加载-->
  	<init-param>
  		<param-name>contextConfigLocation</param-name>
  		<param-value>classpath:spring/springmvc.xml</param-value>
  	</init-param>
  </servlet>
  
  <servlet-mapping>
  	<servlet-name>springmvc</servlet-name>
  	<url-pattern>*.do</url-pattern>
  </servlet-mapping>
  
  
  <context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:spring/spring-security.xml</param-value>
	 </context-param>
	 <listener>
		<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
	 </listener>
	
	
	
	<!-- 过滤器代理,name值必须为:springSecurityFilterChain -->
	 <filter>  
		<filter-name>springSecurityFilterChain</filter-name>  
		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>  
	 </filter>  
	 
	 <filter-mapping>  
		<filter-name>springSecurityFilterChain</filter-name>  
		<url-pattern>/*</url-pattern>  
	 </filter-mapping>
	
</web-app>

9.service.web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	version="2.5">	
	
	<!-- 加载spring容器 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:spring/applicationContext*.xml</param-value>
	</context-param>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
	
</web-app>

10.web.springmvc.xml

<?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:context="http://www.springframework.org/schema/context"
	xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
	<context:property-placeholder location="classpath:config/application.properties" />

	<mvc:annotation-driven>
		<mvc:message-converters register-defaults="true">
			<bean
				class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
				<property name="supportedMediaTypes" value="application/json" />
				<property name="features">
					<array>
						<value>WriteMapNullValue</value>
						<value>WriteDateUseDateFormat</value>
					</array>
				</property>
			</bean>
		</mvc:message-converters>
	</mvc:annotation-driven>

	<!-- 配置多媒体解析器 -->
	<bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="defaultEncoding" value="UTF-8"></property>
		<!-- 设定文件上传的最大值5MB,5*1024*1024 -->
		<property name="maxUploadSize" value="5242880"></property>
	</bean>


	<!-- 引用dubbo 服务 -->
	<dubbo:application name="pinyougou-manager-web" />
	<dubbo:registry address="zookeeper://192.168.25.129:2181" />
	<dubbo:annotation package="com.pinyougou.manager.controller" />

</beans>

11.service.xml

<?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:context="http://www.springframework.org/schema/context"
	xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <dubbo:protocol name="dubbo" port="20881"></dubbo:protocol>
	<dubbo:application name="pinyougou-sellergoods-service"/>  
    <dubbo:registry address="zookeeper://192.168.25.129:2181"/>
    <dubbo:annotation package="com.pinyougou.sellergoods.service.impl" />  
   
   
</beans>
<?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:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
 

    <!-- 事务管理器  -->  
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
        <property name="dataSource" ref="dataSource" />  
    </bean>  
      
    <!-- 开启事务控制的注解支持 -->  
    <tx:annotation-driven transaction-manager="transactionManager"/>
   
</beans>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值