SSH集成开发,老是无法范文index.jsp页面。还有顺带问下:iE和火狐浏览器怎么对div+css支持不是很好呢,页面很乱,div不能居中(margin:0 auto),一下问部分文件代码:
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
        <filter-name>OpenSessionInViewFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
        <filter-name>OpenSessionInViewFilter</filter-name>
        <url-pattern>/*</url-pattern>
</filter-mapping>
 
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:beans.xml</param-value>
</context-param>
<listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
       <param-name>config</param-name>
       <param-value>/WEB-INF/struts-config.xml</param-value>
     </init-param>
     <init-param>
        <param-name>debug</param-name>
        <param-value>3</param-value>
        </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
   </servlet>
 
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>struts-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd"><struts-config>
  <form-beans >
    <form-bean name="userForm" type="com.xiaonei.web.form.UserForm" />
    <form-bean name="albumForm" type="com.xiaonei.struts.form.AlbumForm" />  </form-beans>  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      input="/WEB-INF/test/test.jsp"
      parameter="flag"
      path="/test"
      type="com.xiaonei.web.action.TestAction"
      validate="false" >
      <forward name="show" path="/WEB-INF/test/showCountry.jsp" />
    </action>
    <action
      attribute="userForm"
      input="/WEB-INF/public/index.jsp"
      name="userForm"
      parameter="flag"
      path="/register"
      scope="request"
      type="com.xiaonei.web.action.RegisterAction"
      validate="false">
      <forward name="regUI" path="/WEB-INF/public/register.jsp" />
      <forward name="regok" path="/WEB-INF/self/home.jsp" />
    </action>
    <action
      attribute="userForm"
      input="/WEB-INF/self/uploadPhoto.jsp"
      name="userForm"
      parameter="flag"
      path="/profile"
      scope="request"
      type="com.xiaonei.web.action.ProfileAction"
      validate="false">
      <forward name="goUploadPhotoUI" path="/WEB-INF/self/uploadPhoto.jsp" />
      <forward name="goHomePageUI" path="/WEB-INF/self/homePage.jsp" />
    </action>
    <action
      attribute="userForm"
      input="/WEB-INF/public/index.jsp"
      name="userForm"
      parameter="flag"
      path="/login"
      scope="request"
      type="com.xiaonei.struts.action.LoginAction"
      validate="false" >
      <forward name="goHomeUI" path="/WEB-INF/self/home.jsp" />
      <forward name="goIndexUI" path="/WEB-INF/public/index.jsp" />
    </action>
    <action
      attribute="albumForm"
      input="/WEB-INF/self/myAlbum.jsp"
      name="albumForm"
      parameter="flag"
      path="/album"
      scope="request"
      type="com.xiaonei.struts.action.AlbumAction"
      validate="false">
      <forward name="goAddAlbumUI" path="/WEB-INF/self/addOrChoiceAlblum.jsp" />
      <forward name="goAddPhotoUI" path="/WEB-INF/self/addPhoto.jsp" />
      <forward name="goMyAlbumUI" path="/WEB-INF/self/myAlbum.jsp" />
      <forward name="goOneAlbumUI" path="/WEB-INF/self/oneAlbum.jsp" />
      <forward name="goOnePhotoUI" path="/WEB-INF/self/onePhoto.jsp" />
    </action>  </action-mappings>
  <!-- 配置请求处理器,就是把action的创建交给spring容器处理 -->
  <controller>
 <set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>
</controller> 
  <message-resources parameter="com.xiaonei.struts.ApplicationResources" />
</struts-config>

解决方案 »

  1.   

    beans.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: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.5.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-2.5.xsd
               http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
               http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    <context:annotation-config/>
    <!-- 配置service 对象 -->
    <!-- 下面这句话表示,让spring自动去扫描以com开头的包的组件(action/service),然后自动完成组装
    <context:component-scan base-package="com"/> -->
    <!-- 配置databaseSource -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.gjt.mm.mysql.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/xiaoneiwang?useUnicode=true&amp;characterEncoding=utf-8"/>
        <property name="username" value="root"/>
        <property name="password" value="123"/>
         <!-- 连接池启动时的初始值 -->
    <property name="initialSize" value="3"/>
     <!-- 连接池的最大值 -->
     <property name="maxActive" value="500"/>
     <!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 -->
    <property name="maxIdle" value="2"/>
    <!--  最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 -->
    <property name="minIdle" value="1"/>
    </bean>
    <!-- 配置sessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
         <property name="dataSource" ref="dataSource"/>
         <property name="mappingResources">
        <list>
          <value>com/xiaoneiwang/domain/City.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Country.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Junior.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Primaryschool.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Province.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Senior.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Techschool.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Town.hbm.xml</value>
          <value>com/xiaoneiwang/domain/University.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Usernet.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Users.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Usersenior.hbm.xml</value>
          <value>com/xiaoneiwang/domain/Useruniversity.hbm.xml</value>
        </list>
         </property>
         <property name="hibernateProperties">
        <value>
         hibernate.dialect=org.hibernate.dialect.MySQLDialect
         hibernate.hbm2ddl.auto=update
             hibernate.show_sql=false
    hibernate.format_sql=false    
      </value>
        </property>
    </bean><!-- 转到注解配置 -->
    <bean id="testService"  class="com.xiaoneiwang.service.TestService">
    <property name="sessionFactory"  ref="sessionFactory"/>
    </bean>
    <bean id="countryServiceImpl" class="com.xiaoneiwang.service.impl.CountryServiceImpl">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <bean id="provinceServiceImpl" class="com.xiaoneiwang.service.impl.ProvinceServiceImpl">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <bean id="universityServiceImpl" class="com.xiaoneiwang.service.impl.UniversityServiceImpl">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean><!-- 配置action -->
    <bean name="/test" class="com.xiaoneiwang.web.action.TestAction">
    <!-- 给该action注入一个service 
    <property name="testService" ref="testService"/> -->
    </bean>
    <bean name="/register" class="com.xiaoneiwang.web.action.RegisterAction">
    <property name="countryService" ref="countryServiceImpl" />
    <property name="provinceService" ref="provinceServiceImpl"/>
    <property name="universityService" ref="universityServiceImpl"/>
    </bean><!-- 配置事务管理器 -->
    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <tx:annotation-driven transaction-manager="txManager"/>
    </beans>