`
CSY_X
  • 浏览: 7214 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

SpringMVC,Spring,MyBatis,Shrio

    博客分类:
  • JAVA
阅读更多

//applicationContext.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: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/context http://www.springframework.org/schema/context/spring-context.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">

<context:component-scan base-package="com.kaishengit">

<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>

</context:component-scan>

<tx:annotation-driven transaction-manager="transactionManager"/>

<context:property-placeholder location="classpath:db.properties"/>

 

<!-- 数据源 -->

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">

<property name="driverClassName" value="${jdbc.driver}"/>

<property name="url" value="${jdbc.url}"/>

<property name="username" value="${jdbc.username}"/>

<property name="password" value="${jdbc.password}"/>

<property name="initialSize" value="5"></property>

<property name="maxActive" value="20"></property>

</bean>

<!-- Session工厂 -->

<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

<property name="dataSource" ref="dataSource"/>

<property name="typeAliasesPackage" value="com.kaishengit.entity"/>

</bean>

<!-- 事务管理器 -->

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

<property name="dataSource" ref="dataSource"/>

</bean>

<!-- Mapper自动扫描 -->

<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">

<property name="basePackage" value="com.kaishengit.dao"/>

</bean>

</beans>

//springmvc-servlet

<?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:context="http://www.springframework.org/schema/context"

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/context http://www.springframework.org/schema/context/spring-context.xsd

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

 

<context:component-scan base-package="com.kaishengit.controller"/>

<mvc:annotation-driven/>

<!-- 视图-控制器映射 -->

<mvc:view-controller path="/" view-name="index"/>

<!-- 处理静态资源 -->

<mvc:resources location="/static/" mapping="/static/**"/>

<!-- 视图解析器 -->

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">

<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>

<property name="prefix" value="/WEB-INF/views/"/>

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

</bean>

<!-- 文件上传解析器 -->

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

<property name="maxUploadSize" value="10000000000"></property>

</bean>

<!-- 过滤器 -->

<mvc:interceptors>

<mvc:interceptor>

<mvc:mapping path="/**"/>

<bean class="com.kaishengit.controller.interceptor.MyInterceptor">

<property name="excluedUrls">

<list>

<value>/</value>

<value>/static</value>

</list>

</property>

</bean>

</mvc:interceptor>

</mvc:interceptors>

</beans>

//web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5" 

xmlns="http://java.sun.com/xml/ns/javaee" 

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

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

 

<!-- springmvc调度器 -->

<servlet>

<servlet-name>springmvc</servlet-name>

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

</servlet>

<servlet-mapping>

<servlet-name>springmvc</servlet-name>

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

</servlet-mapping>

 

<!-- 初始化Spring容器  -->

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

 

<!-- spring 容器初始化参数文件位置 -->

<context-param>

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

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

</context-param>

 

<!-- Shiro配置 -->

<filter>

<filter-name>ShiroFilter</filter-name>

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

</filter>

<filter-mapping>

<filter-name>ShiroFilter</filter-name>

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

</filter-mapping>

</web-app>

 

 //applicationContext-shrio.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: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

">

 

<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">

<property name="realm" ref="shiroService"/>

<property name="cacheManager" ref="cacheManager"/>

</bean>

<bean id="ShiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">

<property name="securityManager" ref="securityManager"/>

<property name="loginUrl" value="/login"/>

<property name="successUrl" value="/home"/>

<property name="unauthorizedUrl" value="/403"/>

<property name="filterChainDefinitions">

<value>

/favicon.ico = anon

/** = authc

</value>

</property>

</bean>

<bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />

<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />

 

</beans>

//UserMapper.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 

"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.kaishengit.dao.UserMapper">

<select id="findById" resultType="User" parameterType="int">

select * from user where id = #{id}

</select>

<select id="findAll" resultMap="allUser" resultType="list">

select * from user

</select>

<resultMap type="User" id="allUser">

<id property="id" column="id"/>

<result property="username" column="username"/>

<result property="password" column="password"/>

</resultMap>

 

<select id="findByUsername" resultType="User" parameterType="string">

select * from user where username = #{username}

<selectKey resultType="long" keyProperty="id" order="BEFORE">

select id_seq.nextval from dual

</selectKey>

</select>

<insert id="save" parameterType="User" >

insert into user (id,username,password)values(#{id},#{username},#{password})

</insert>

<update id="update" parameterType="User">

update user set username = #{username},password = #{password} where id =#{id}

</update>

</mapper>

分享到:
评论

相关推荐

    springmvc spring mybatis shiro 整合之个人博客

    在本项目中,"springmvc spring mybatis shiro 整合之个人博客"是一个基于Java技术栈构建的个人博客系统,它集成了SpringMVC、Spring、MyBatis和Shiro四大核心框架。下面将详细解析这四个技术以及它们在个人博客系统...

    SpringMVC-Mybatis-Shiro-redis

    《SpringMVC-Mybatis-Shiro-Redis:构建安全高效的Web应用》 在现代Web开发中,构建一个高效且安全的后端系统是至关重要的。本文将深入探讨一个基于SpringMVC、Mybatis、Shiro和Redis的Web应用架构,这四个组件共同...

    SpringMVC-Mybatis-Shiro-redis-master

    在这样的集成环境中,"master"分支应该包含了SpringMVC的配置文件(如spring-mvc.xml)、MyBatis的配置文件(mybatis-config.xml和Mapper XML文件)、Shiro的配置文件(shiro.ini或对应的Java配置)以及Redis的配置...

    基于SpringBoot+Spring+SpringMvc+Mybatis+Shiro+Redis 开发单点登录管理系统源码

    基于 SpringBoot + Spring + SpringMvc + Mybatis + Shiro+ Redis 开发单点登录管理系统 基于 SpringBoot + Spring + SpringMvc + Mybatis + Shiro+ Redis 开发单点登录管理系统 基于 SpringBoot + Spring + ...

    springmvc+mybatis+shiro jar包

    在"springmvc+mybatis+shiro jar包"中,我们可以找到这三个框架的核心库和其他相关依赖,这些是进行整合开发的基础。以下将分别介绍这些框架的关键知识点: 1. **Spring MVC**: - **DispatcherServlet**:作为...

    Spring+SpringMVC+MyBatis+Shiro+MySQL+Redis+Maven实现的通用权限管理系统

    Spring+SpringMVC+MyBatis+Shiro+MySQL+Redis+Maven+EasyUI+Bootstrap实现的通用权限管理系统。 Spring+SpringMVC+MyBatis+Shiro+MySQL+Redis+Maven+EasyUI+Bootstrap实现的通用权限管理系统 Spring+SpringMVC+...

    spring+springmvc+mybatis+shiro框架搭建

    本项目采用的是"Spring+SpringMVC+MyBatis+Shiro"的框架集合,也被称为SSMShiro框架。这是一个广泛应用于企业级开发的组合,因为它能够提供灵活的控制层、强大的持久层支持以及安全的权限管理。 **Spring框架**是...

    OA协同办公与管理系统(毕业设计)Spring+SpringMVC+Mybatis+Shiro+JqueryEasyUI.zip

    OA协同办公与管理系统(毕业设计)Spring+SpringMVC+Mybatis+Shiro+JqueryEasyUIOA 哦OA协同办公与管理系统(毕业设计)Spring+SpringMVC+Mybatis+Shiro+JqueryEasyUIOA协同办公与管理系统(毕业设计)Spring+...

    spring+springmvc+mybatis+shiro

    标题中的"spring+springmvc+mybatis+shiro"是一个常见的Java Web开发技术栈,它涵盖了四个关键组件:Spring框架、Spring MVC、MyBatis以及Apache Shiro。这些技术一起构建了一个功能强大的后端系统,提供了全面的...

    SSM框架(Spring+SpringMVC+MyBatis)+shiro+Maven.zip

    ● 实现方法: 使用MySQL 建立数据库。服务端使用SSM框架(Spring+SpringMVC+MyBatis)+shiro+Maven,使用Myeclipse进行开发。前端使用MUi和HUI框架和vue(与后台交互模板)和Html5+css3来实现移动端App的开发。

    springmvc+mybatis+shiro

    Spring MVC、MyBatis 和 Shiro 是三个在Java Web开发中广泛应用的开源框架。Spring MVC 是 Spring 框架的一部分,用于构建 MVC(Model-View-Controller)模式的Web应用程序,提供灵活的请求处理和视图渲染。MyBatis ...

    springmvc+mybatis+mysql+shiro

    SpringMVC、MyBatis、MySQL和Shiro是四个在Java Web开发中广泛使用的框架和技术。下面将分别介绍它们的核心概念、如何整合以及在实际应用中的作用。 **SpringMVC** 是Spring框架的一部分,用于构建Web应用程序的...

    spring mybatis shiro 共6天 8部分 第6部分 传智 燕青主讲 非常好

    spring mybatis shiro 共6天 8部分 第6部分 传智 燕青主讲 非常好

    学习视频 springmvc mybatis shiro

    在IT行业中,SpringMVC、MyBatis和Shiro是三个非常重要的框架,它们分别用于构建Web应用程序的控制层、数据访问层以及安全认证和授权。让我们深入了解一下这三个技术及其在实际开发中的应用。 首先,SpringMVC是...

    springMvc+spring+mybatis+shiro+redis+ehcache后台管理系统.zip

    本后台管理系统,采用流行的框架springMvc+spring+mybatis+shiro+redis+ehcache开发,实现了权限管理(菜单权限、数据权限),solr全文搜索引擎,activiti工作流程引擎,cas单点登陆等功能,完善的代码生成器 后期还...

    SSM(Spring+SpringMVC+MyBatis)多数据源配置框架

    SSM(Spring、SpringMVC和MyBatis)是一个经典的Java Web开发框架组合,用于构建高效、灵活且可维护的企业级应用。这个框架整合了Spring的IoC(Inversion of Control,控制反转)和AOP(Aspect Oriented Programming...

    SpringMvc整合mybatis和shiro权限管理系统

    本项目名为“SpringMvc整合mybatis和shiro权限管理系统”,旨在实现一个基于SpringMVC、MyBatis、Maven、EasyUI和Shiro的全面解决方案。下面将详细介绍这些技术及其整合过程中的关键知识点。 首先,**SpringMVC** ...

    仓库管理系统,Spring+SpringMVC+Mybatis

    仓库管理系统,前端使用BootStrap+JQuery+JSP,后端使用Spring+SpringMVC+Mybatis,数据库使用MySQL,开发平台IntelliJ IDEA+open JDK1.8 amd64

    spring springmvc mybatis shiro 以及 ehcache(配合shiro实现缓存验证 配合spring实现二级缓存)

    spring springmvc mybatis shiro 以及 ehcache(配合shiro实现缓存验证 配合spring实现二级缓存) 测试 二级缓存 访问http://localhost:8080/vkblog/test/ehcacheuserlist.action 测试 访问限制 访问任意的action

    Maven搭建Spring+SpringMVC+Mybatis+Shiro

    Maven搭建Spring+SpringMVC+Mybatis+Shiro,包含数据库测试文件,本人刚刚学习Shiro,欢迎大家指导指正

Global site tag (gtag.js) - Google Analytics