Struts2 + Spring 3验证问题

时间:2011-09-27 19:11:06

标签: spring struts2

我正在尝试使用struts2验证。我有一个Struts2.2.3和Spring 3.0.5的设置。我有一个-validation.xml。字段正在验证,并且错误消息将显示在服务器控制台上,但它不会显示在UI上。此外,操作不会转发到为“input”标记指定的结果。 我的action类没有从ActionSupport扩展而是实现了Preparable。这可能是问题吗?

所以我也尝试将我的Action类定义为

    public class CandidateAction extends ActionSupport implements Preparable

在点击页面时出现以下错误

    Invalid action class configuration that references an unknown class named [candidateAction]

即使我在应用程序context.xml

中定义了名为“candidateAction”的bean

的applicationContext.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: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
            class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

        <bean id="dao" class="org.kovid.dao.impl.DaoImpl" />

        <bean id="entityManagerFactory"
            class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                    <property name="database" value="MYSQL" />
                    <property name="showSql" value="true" />
                </bean>
            </property>
        </bean>

        <bean id="dataSource"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="com.mysql.jdbc.Driver" />
            <property name="url" value="jdbc:mysql://localhost/xyz" />
            <property name="username" value="abc" />
            <property name="password" value="abc" />
        </bean>

        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory" />
        </bean>

        <tx:annotation-driven transaction-manager="transactionManager" />

        <bean id="baseAction" scope="prototype" class="org.kovid.action.BaseAction">
        </bean>
        <bean id="candidateAction" scope="prototype"
            class="org.kovid.matrimony.action.CandidateAction">
            <constructor-arg ref="dao" />
        </bean>

        <bean id="simpleSearchAction" scope="prototype"
            class="org.kovid.matrimony.action.SimpleSearchAction">
            <constructor-arg ref="dao" />
        </bean>

        <bean id="advanceSearchAction" scope="prototype"
            class="org.kovid.matrimony.action.AdvanceSearchAction">
            <constructor-arg ref="dao" />

        </bean>
        <bean id="imageAction" scope="prototype"
            class="org.kovid.matrimony.action.ImageAction">
            <constructor-arg ref="dao" />
        </bean>


        </beans>

0 个答案:

没有答案