springMVC+hibernate+tomcat出现问题


最近在学习springMVC,在整合中出现了问题,配置过程基本没有问题,用Intellij idea部署成功启动,页面也显示了,但在提交登录的时候游览器一直显示pending,而后台没有任何错误,我进行了debug,发现并没有进入系统,初步估计是tomcat的问题,可能是系统启动后造成的tomcat的问题。但tomcat也没有报任何异常,求解。而且保持pending后我试图关闭tomcat但其未响应,只能强制关闭。

web.xml: http://java.sun.com/xml/ns/javaee/web... version="2.5"> log4jConfigLocation WEB-INF/log4j.properties


 <listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:spring-*.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>controller</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring-controller.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>controller</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.css</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.gif</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.jpg</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.js</url-pattern>
</servlet-mapping>

spring-config.xml:

http://www.springframework.org/schema... http://www.springframework.org/schema... http://www.springframework.org/schema... http://www.springframework.org/schema...> errors/error errors/err

spring-controller.xml:

http://www.springframework.org/schema... http://www.springframework.org/schema... http://www.springframework.org/schema... http://www.springframework.org/schema...>


 <context:component-scan base-package="com.gujiaqi" use-default-filters="false">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>
<!-- ... -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/page/"/>
    <property name="suffix" value=".jsp"/>
</bean>

spring-hibernate.xml: http://www.springframework.org/schema... http://www.springframework.org/schema... http://www.springframework.org/schema/tx http://www.springframework.org/schema... http://www.springframework.org/schema... http://www.springframework.org/schema...>


 <!--  配置hibernate SessionFactory-->
<bean id="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hiberante.format_sql">true</prop>
        </props>
    </property>
    <property name="packagesToScan">
        <!-- 这里为SessionFactory配置了实体bean的自动扫描 -->
        <list>
            <value>com.gujiaqi.bean</value>
        </list>
    </property>
</bean>

<!-- 事务管理器 -->
<bean id="transactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!--启动spring注解功能-->
<tx:annotation-driven transaction-manager="transactionManager" />
<aop:config>
    <aop:pointcut id="serviceOperation" expression="execution(* com.gujiaqi.service.impl.*.*(..))" />
    <aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice" />
</aop:config>
<!-- 事务代理类 -->


<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="update*" propagation="REQUIRED"/>
        <tx:method name="save*" propagation="REQUIRED"/>
        <tx:method name="add*" propagation="REQUIRED"/>
        <tx:method name="create*" propagation="REQUIRED"/>
        <tx:method name="do*" propagation="REQUIRED"/>
        <tx:method name="del*" propagation="REQUIRED"/>
        <tx:method name="remove*" propagation="REQUIRED"/>
        <tx:method name="get*" read-only="true" />
        <tx:method name="query*" read-only="true" />
        <tx:method name="find*" read-only="true" />
        <tx:method name="*"/>
    </tx:attributes>
</tx:advice>

spring-mvc hibernate

茵蒂克丝酱 11 years ago

Your Answer