struts+spring+hibernate搞了一天,總是有Servlet action is not available異常,高手指教一下

yinleiyoung發表於2005-12-22
一開始我先是struts1.1 + spring1.2.6,沒有問題,一切正常
後來我加上hibernate3,改動applicationContext.xml後,編譯是總是產生The requested resource (Servlet action is not available) is not available.異常,高手幫我看一下有什麼問題

struts-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config >
<form-beans>
<form-bean name="loginform" type="com.ssh.pro.form.LoginForm" />
</form-beans>

<action-mappings>

<action input="index.jsp" name="loginform" path="/login" scope="request" type="org.springframework.web.struts.DelegatingActionProxy" validate="false">
<forward name="success" path="/admin/LoginSuccess.jsp" />
</action>

</action-mappings>

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
</plug-in>

</struts-config>


applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<bean name="/login" class="com.ssh.pro.action.LoginAction" singleton="false">
<property name="manageinfoDAO">
<ref bean="manageinfoDAOProxy" />
</property>
</bean>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@10.10.10.112:1521:orcl</value>
</property>
<property name="username">
<value>trms</value>
</property>
<property name="password">
<value>trmswaygoing</value>
</property>
</bean>

<!--sessionFactory-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>com/ssh/pro/dto/Manageinfo.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>

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

<bean id="manageinfoDAO" class="com.ssh.pro.dao.ManageinfoDAO">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>

<bean id="manageinfoDAOProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="manageinfoDAO" />
</property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="is*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>


</beans>



DAO:
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class ManageinfoDAO extends HibernateDaoSupport{

private static String hql = "from Manageinfo m where m.username=? ";

public boolean isValidUser(String username, String password) {

List userList = this.getHibernateTemplate().find(hql, username);

if (userList.size() > 0) {

return true;

}

return false;

}

}

相關文章