我现在的程序是使用struct和spring实现的,我现在想在已有程序的基础上使用tiles程序的部分代码如下:
appcontext.xml部分代码<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
   "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
     <!--通过JNDI获得数据源的引用-->
     <bean id="zxdyDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
         <property name="jndiName">
              <value>java:comp/env/jdbc/zxdy</value>
         </property>
     </bean>
    <!-- 配置JdbcTemplate的bean -->
     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource">
           <ref local="zxdyDataSource"/>
        </property>
     </bean>
     <!-- 配置DBUtil的bean 并注入资源-->
     <bean id="DBUtil" class="com.easygoing.util.DBUtil">
        <property name="jt">
           <ref local="jdbcTemplate"/>
        </property>
        <property name="ds">
         <ref local="zxdyDataSource"/>
        </property>
     </bean>
     <!-- Struts Action在Spring中对应的Bean   -->
     <!-- 本来有很多Action,但是为了方便只留下了一个,其余的一样   -->
    <!--修改密码的Action-->
    <bean id="CPWDAction" class="com.easygoing.form.action.ChangePwdAction" singleton="false">
        <property name="dbu">
           <ref local="DBUtil"/>
        </property>
    </bean>   
</beans>
struts.xml的部分代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd"><struts>
   <package name="zxdyQT" extends="struts-default">
    <!--配置拦截器-->
    <interceptors>
<interceptor name="mi" class="com.easygoing.util.MyInterceptor"/>
<interceptor-stack name="zxdydefault">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="mi"/>
</interceptor-stack>
</interceptors>
<!--配置默认拦截器-->
<default-interceptor-ref name="zxdydefault"/>
<global-results>
          <result name="LOGIN">/login.jsp</result>
</global-results>
   
      <action name="CPWDAction" class="CPWDAction">
          <result name="success">
              /tiles-components/changePwd.jsp
          </result>
          <result name="login">/login.jsp</result>
      </action>
   </package></struts>web.xml代码如下<?xml version="1.0" encoding="gbk"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><resource-ref>
   <description>DB Connection</description>
   <res-ref-name>jdbc/zxdy</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
</resource-ref>
   
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/appcontext.xml</param-value>
    </context-param>    
    <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>
           org.apache.struts2.dispatcher.FilterDispatcher
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>    <welcome-file-list>
<welcome-file>forward.jsp</welcome-file>
    </welcome-file-list>
</web-app>

解决方案 »

  1.   

    tiles 看>http://baike.baidu.com/view/25374.htm?fr=ala0_1
      

  2.   

    那个好像是不是struct2中tiles的使用方法,我这几天看了很多关于struct2整合tiles的方法,但是有spring的情况下好像又不太一样
      

  3.   

    http://blog.sina.com.cn/s/blog_5d96d99a0100d5q5.html
    LZ看看这个  不知道能不能帮到你!
      

  4.   


    看了 照着做了几遍 不对 不知道为什么郁闷ing