Java Resources


action                                            处理请求返回结果

entity                                             实体对象

mybatis                                          简单ORM映射

service                                           业务处理

interceptor                                     拦截器

globalMessages.properties               全局资源文件

log4j.properties                              log4j日志

struts.xml                                      struts配置文件

mybatis.xml                                   mybatis配置文件


web/index.jsp                                  jsp页面文件

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%String path = request.getContextPath();String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello</title>
</head>
<body>
<h2>Hello!</h2>
</body>
</html>

web/WEB-INF/applicationContext.xml Spring配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"><!-- Begin Base --><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><property name="driverClassName" value="com.mysql.jdbc.Driver" /><property name="url"value="jdbc:mysql://192.168.1.199:3307/gwanda?useUnicode=true&amp;characterEncoding=UTF-8" /><property name="username" value="root" /><property name="password" value="root" /></bean><!-- sqlSessionFactory工厂bean,如果有定义别名等mybatis基本配置 需要通过configLocation属性指定mybatis配置文件所在位置 如果mapper.xml和接口interface不在同一个目录,需要通过mapperLocations属性指定所有mapper.xml文件的位置,如: <property name="mapperLocations" value="classpath*:sample/config/mappers/**/*.xml" /> 因为本项目的mapper.xml和interface在同一目录,故省略此属性的配置 --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource"></property><property name="configLocation" value="classpath:mybatis.xml"></property></bean><!-- MapperScannerConfigurer会自动创建所有MapperFactoryBean,通过以下配置可以不用再手工把所 的MapperFactoryBean加入到spring的文件中,MapperFactoryBean是指以下的配置: <bean id="schoolMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"> <property name="mapperInterface" value=" cn.e21.lesson.mybatis.mappers.SchoolMapper" /> <property name="sqlSessionFactory" ref="sqlSessionFactory" /> </bean> 通过配置MapperScannerConfigurer,可以省略MapperFactoryBean在spring中的配置 --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="mappers映射文件夹" /></bean><!-- End Base --><!-- Begin DAO --><!-- End DAO --><!-- Begin Service --><!-- End Service --><!-- Begin Struts2 Action --><!-- End Struts2 Action -->
</beans>

web/WEB-INF/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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"><display-name>gwanda</display-name><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><!-- *.action --><url-pattern>/*</url-pattern></filter-mapping><welcome-file-list><welcome-file>login</welcome-file></welcome-file-list><context-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/applicationContext.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><context-param><param-name>log4jConfigLocation</param-name><param-value>/WEB-INF/classes/log4j.properties</param-value></context-param><listener><listener-class>org.springframework.web.util.Log4jConfigListener</listener-class></listener>
</web-app>

转载于:https://www.cnblogs.com/jonkey/archive/2012/06/26/2564130.html

struts+spring+mybatis介绍相关推荐

  1. 简单struts,spring,mybatis组合使用

    由于本人是新手,对这些框架又不熟悉,但是现在要整合它们三个,可费了我老大的劲了,主要是调试,调来调去,就是不能运行成功,感觉就是一只没头的黑苍蝇乱飞,经过我一多天的时间终于给整出来了,下面简单的写写执 ...

  2. Spring入门介绍

    1.0.什么是框架 运用别人开发一部分的软件---->半成品软件 框架的作用: 1.1.简介 Spring:春天->给软件行业带来了春天! 2002,首次推出了Spring框架的雏形:in ...

  3. Eclipse+Maven+Struts2+Spring+Mybatis完整搭建

    一.前言 公司框架是SSH,hibernate用的越来越少,做了几年后,也懒得用了,springjdbc玩到现在,maven,mybatis没用到一直都没去接触,感慨现在技术真是发展越来越快,有点落伍 ...

  4. idea springmvc_SSM三大框架使用Maven快速搭建整合(SpringMVC+Spring+Mybatis)

    本文介绍使用SpringMVC+Spring+MyBatis三大框架使用Maven快速搭建一个demo,实现数据从数据库中查询返回到页面进行展示的过程. 技术选型:SpringMVC+Spring+M ...

  5. 【SSH进阶之路】Struts + Spring + Hibernate 进阶开端(一)

    Long Long ago.就听说过SSH.起初还以为是一个东东,详细内容更是不详,总认为高端大气上档次,经过学习之后才发现,不不过高大上,更是低调奢华有内涵,经过一段时间的研究和学习SSH框架的基本 ...

  6. spring事务介绍

    一.spring事务介绍 spring事务优点 对不同的api进行统一编程模型,如JTA,JDBC,Hibernate,JPA,JDO... 支持声明式事务 简化编程式事务api 对spring数据层 ...

  7. Spring入门介绍:

    Spring入门介绍 Spring诞生: 创建Spring的目的就是用来替代更加重量级的的企业级Java技术 简化Java的开发 基于POJO轻量级和最小侵入式开发 通过依赖注入和面向接口实现松耦合 ...

  8. Spring之旅—Spring模块介绍

    1.0  Spring模块介绍 核心容器(Spring Core) 核心容器提供Spring框架的基本功能.Spring以bean的方式组织和管理Java应用中的各个组件及其关系.Spring使用Be ...

  9. SpringMVC+Spring+mybatis

    1. 外部架包依赖引入1.1 spring框架依赖包引入 spring-contextspring-beansspring-jdbcspring aspectsspring-webmvc1.2 spr ...

  10. SpringMVC Spring Mybatis Druid SpringSession集成例子

    本文主要介绍SpringMVC Spring Mybatis Druid SpringSession如何集成. 源代码分享在github https://github.com/chenhaifeng2 ...

最新文章

  1. Linux下查看显示器输出状态以及修改显示器工作模式(复制 or 扩展)
  2. 让网站性能最佳的34条黄金守则
  3. python学习笔记:第19天 类的约束、异常、MD5和logging
  4. 自定义request_ASP.NET Core 学习之自定义异常处理
  5. php 地址获取百度经纬度,根据百度api获取一个地址的经纬度
  6. Spring(13)——PropertyPlaceholderConfigurer
  7. nuxt解决首屏加载慢问题_为什么Nuxt.js创建服务器端渲染的应用程序更有优势?...
  8. 硬件课程设计:步进电机控制系统
  9. 14.Java实现UDP通信
  10. 美团java笔试题_美团笔试题目(Java后端5题2小时)
  11. 工业以太网交换机常见的几种故障类型及分析排查方法
  12. 基于Selenium实现网易云音乐的登录
  13. 微机中的实际地址、物理地址、有效地址、逻辑地址之间的区别
  14. 有关计算机软件的心得1500,plc心得体会1500字
  15. 用AutoCAD画尺寸链小结
  16. day inset_SetIP三星网络打印IP设置软件
  17. html浅色背景,深色背景和浅色标签
  18. 分类指标:准确率、精确率、召回率、F1 score以及ROC、AUC、宏平均、加权平均
  19. 微信支持搜索后批量删除好友,语音进度条自由拖动
  20. PPT | ​云上安全防卫战

热门文章

  1. Docker 概述 与 CentOS 上安装、卸载、启动
  2. cmd 获取ftp没反应_python笔记13-执行cmd指令
  3. 阶段5 3.微服务项目【学成在线】_day02 CMS前端开发_25-前后端请求响应流程小结...
  4. 阶段3 1.Mybatis_12.Mybatis注解开发_5 mybatis注解建立实体类属性和数据库表中列的对应关系...
  5. C语言编程-9_4 字符统计
  6. centos6.5和centos7如何搭建php环境(包括php7)
  7. CentOS6 图形界面(gnome)安装(转)
  8. 让 ADO.NET 2.0 的 SqlCommand 和 SqlDataAdapter 合作
  9. Maxtocode 2.0 试用版发布
  10. spring AOP 代理(静态与动态+使用cglib实现)