struts+spring+hibernate搞了一天,總是有Servlet action is not available異常,高手指教一下
一開始我先是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;
}
}
後來我加上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;
}
}
相關文章
- No Bean named 'Xxx' available 異常報錯BeanAI
- 什麼是異常?python處理異常的方式有幾種?Python
- 什麼是異常
- OOM異常型別總結OOM型別
- Java常見知識點彙總(⑨)——異常Java
- 什麼是中斷?什麼是異常?它們有何區別?
- 課時32:異常處理:你不可能總是對的
- golang 執行系統命令 ps aux | grep "xxxx",總是異常退出GolangUX
- 課時33:異常處理:你不可能總是對的2
- servlet再次總結Servlet
- 【Java面試】請簡單說一下你對受檢異常和非受檢異常的理解Java面試
- Servlet 常見的註解Servlet
- 異常和異常呼叫鏈
- 異常篇——異常記錄
- 異常篇——異常處理
- Python異常處理回顧與總結Python
- kubernetes叢集的安裝異常彙總
- Servlet是什麼?Servlet
- servlet知識總結Servlet
- Servlet面試總結Servlet面試
- 許可權修飾符,方法及異常瞭解一下
- 異常-異常的注意事項
- Java 異常(二) 自定義異常Java
- 異常-編譯期異常和執行期異常的區別編譯
- 異常?
- 異常
- 如果我是python高手Python
- 異常-異常的概述和分類
- 異常-throws的方式處理異常
- hibernate異常之--count查詢異常
- python異常處理的流程是什麼?Python
- Java常出現的異常解決方法總結(不斷更新)Java
- 77種Java異常總結 附解決方案Java
- 知識點-Spring Boot 異常處理彙總Spring Boot
- 兩種異常(CPU異常、使用者模擬異常)的收集
- jmu-Java-06異常-01-常見異常Java
- 關於Servlet小總結Servlet
- 為什麼要有 Servlet ,什麼是 Servlet 容器,什麼是 Web 容器?ServletWeb
- Java 異常表與異常處理原理Java