三大框架struts+spring+ibatis


这是我们公司的包结构,包结构不用多说,大家都看的懂,jdbc.properties这个配置文件是在spring里面要用的访问数据库的配置

log4j是一个日志的配置文件,说明错误的一些还有访问的一些信息写入到哪里

sqlMapConfig配置文件是ibatis的总配置文件,下面写的就是有哪些mapping配置文件,放置的位置就在和entities包下,每一个包写一个配置一个

如果,要涉及要多表查询,就要再创建一个类就好,把2张表中用到的属性,插入到这个类里面

spring-config这个文件夹下放的就是spring的几个配置文件

一个写的就是action的创建,一个是biz层的创建,还有就是DAO

其实struts的action可以用spring来创建,用的就是加了一句话


    <constant name="struts.objectFactory" value="spring" />


这些包结构配置后之后就是配置web.xml

就是告诉tomcat哪些是struts配置文件,哪些是spring配置文件,让tomcat启动的时候,就可以创建了



<?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>HD_U</display-name>
  <context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>HD_U.root</param-value>
  </context-param>
    <listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>//添加日志类的监听
  </listener>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>//spring的监听类
  </listener>
  <context-param>
    <param-name>log4jConfigLocation</param-name>//日志类监听的初始化的参数,告诉配置文件在哪里
    <param-value>classpath:log4j.properties</param-value>
  </context-param>
  <filter>
    <filter-name>struts2</filter-name>//struts2的单控制器
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <context-param>
    <param-name>contextConfigLocation</param-name>//spring的监听类告诉spring配置文件在哪里
    <param-value>classpath*:/spring-config/applicationContext*.xml</param-value>
  </context-param>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>InitServlet</display-name>
    <servlet-name>InitServlet</servlet-name>
    <servlet-class>com.hdu.web.common.InitServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
</web-app>

转载于:https://my.oschina.net/jiMap/blog/665832

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值