配置文件如下: 
1 web.xml 
<?xml version="1.0" encoding="UTF-8"?>   
<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">   
       
       
 <filter>   
        <filter-name>struts</filter-name>   
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>   
    </filter>   
      
    <filter>   
        <filter-name>hibernateFilter</filter-name>   
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>   
    </filter>   
      
   <filter-mapping>   
        <filter-name>struts</filter-name>   
        <url-pattern>/*</url-pattern>   
   </filter-mapping>   
      
   <filter-mapping>   
        <filter-name>hibernateFilter</filter-name>    
        <url-pattern>/*</url-pattern>   
   </filter-mapping>   
     
     
  <context-param>   
    <param-name>contextConfigLocation</param-name>   
    <param-value>classpath:applicationContext-*.xml</param-value>   
 </context-param>   
    
 <listener>   
    <listener-class>   
        org.springframework.web.context.ContextLoaderListener   
    </listener-class>   
 </listener>   
     
  
  <welcome-file-list>   
    <welcome-file>login.jsp</welcome-file>   
  </welcome-file-list>   
</web-app>  2 struts.xml <?xml version="1.0" encoding="GBK"?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.objectFactory" value="spring"/>
    
<package name="test" extends="struts-default">
    <global-results>
       <result name="error">/error.jsp</result>
    </global-results>

<action name="login" class="loginAction">
   <result name="success">/main.jsp</result>
   <result name="login">/login.jsp</result>
   <result name="input">/login.jsp</result>
</action>


   <action name="list" method="listadmin" class="listadminAction">
            <result>/list.jsp</result>
        </action>                                                                                         </package>
</struts>
3 application-db.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@192.168.0.1:1521:TEST">
</property>
<property name="username" value="test"></property>
<property name="password" value="123456"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</prop>
<prop key="show_sql">true</prop>
                <prop key="format_sql">true</prop>

</props>
</property>
<property name="mappingResources">
<list>
<value>Sysadmin.hbm.xml</value>
</list>
</property>
</bean>
</beans>
4 application-dao.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="sysadminDAO" class="SysadminDAOImpl">
  <property name="sessionFactory">
   <ref bean="sessionFactory"/>
  </property>
</bean></beans>
5 application-service 
<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">


<bean id="sysadminManageService" class="SysadminManageServiceImpl">
<property name="sysadminDAO">
<ref bean="sysadminDAO"/>
</property>
</bean>

<aop:config>
<aop:pointcut id="serviceOperation" expression="execution(*ServiceImpl.*(..))"/>
<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice"/>
</aop:config>

<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>


</beans>
6 application-action <?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">


<bean id="loginAction" class="LoginAction" scope="prototype">
<property name="sysadminManageService">
<ref bean="sysadminManageService"/>
</property>
</bean>
<bean id="listadminAction" class="ListadminAction" scope="prototype">
<property name="sysadminManageService">
<ref bean="sysadminManageService"/>
</property>
</bean>

</beans>
JSP页面如下: login.jsp , 该页面可以通过, 登录测试成功 <%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
 <Form action="login.action" method="post"  name="form1" id="form1"  >
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              
              <TBODY>
              <TR>
                <TD height=120 align="center" valign="bottom">
                <dir>
                  <span class="STYLE1"><s:actionerror/></span></dir>
                </TD></TR>
                           <TR>
                <TD>
                 
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD width=235 height=24>
                        <DIV align=right><span class="STYLE1">用户名:</span></DIV></TD>
                      <TD><INPUT type="text" name="ucode" id="ucode" size="15">                      
                      </TD>
                    </TR>
                    <TR>
                      <TD height=24>
                        <DIV align=right><span class="STYLE1">密 码:</span></DIV></TD>
                      <TD>
                      <INPUT type="password" name="upwd" id="upwd" size="15">
                      </TD>
                                        </TR>
                   </TBODY></TABLE></TD></TR>
                            <TD height=24>
                  <DIV align=center>
                <INPUT type="submit" id="Submit1" value="登陆" name="Submit1"> 
                    </DIV></TD></TR>
              </TBODY></TABLE>
              </Form>

解决方案 »

  1.   

    列表显示用户信息页面list.jsp 该页面始终无数据显示, 初学不知道什么原因,请各位帮忙! 
    Java代码 
    <%@ page contentType="text/html; charset=UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <html><body>    <s:iterator value="sysadmins">
                  <s:property value="ucode" />
                   <s:property value="uname" />
     
        </s:iterator></body>
    </html>该页面始终无数据显示, 初学不知道什么原因,请各位帮忙!