首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

急struts+hibernate+spring出现http 404 servlet action找不到的有关问题,希望

2012-02-20 
急!struts+hibernate+spring出现http 404servlet action找不到的问题,希望高手指点web.xmlservletservl

急!struts+hibernate+spring出现http 404 servlet action找不到的问题,希望高手指点
web.xml

 <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>
  
struts-config.xml
  <struts-config>
<form-beans>
  <form-bean name="giveForm" typ="give.form.GiveForm"/>
</form-beans>
<global-exceptions />
<global-forwards />
  <action-mappings>
<action
path="/agree" 
type="org.springframework.web.struts.DelegatingActionProxy" 
name="giveForm"
scope="request"

validate="false"
>
<forward name="success" path="/give/success.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>

 spring的配置文件,分了三个文件来写的。
  application_data.xml
  <bean id="dataSource" 
  class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  <property name="driverClassName">
  <value>com.mysql.jdbc.Driver</value>
  </property>
  <property name="url">
  <value>jdbc:mysql://localhost:3306/test</value>
  </property>
  <property name="username">
  <value>root</value>
  </property>
  <property name="password">
  <value>root</value>
  </property>
  </bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>give/entity/Give.hbm.xml</value>

</list>
</property>
</bean>


<bean id="GiveDAO"
class="give.dao.GiveDAO">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
  application_view.xml


  <bean name="/agree" class="give.action.GiveAction">  
  <property name="giveService"> 
  <ref bean="giveService" />
  </property>
   
  </bean> 
  application_service.xml
  <bean id="giveService" class="give.service.GiveService" >
  <property name="giveDAO"> 
  <ref bean="GiveDAO" />
  </property>  
  </bean>
 applicationContext.xml
  <import resource="/spring/application_data.xml"/>
<import resource="/spring/application_service.xml"/>
<import resource="/spring/application_view.xml"/>
请教,不知哪出了问题!老报servlet action 找不到的问题?
 


[解决办法]
报异常贴出来

估计是找不到"/agree"对应的action


[解决办法]
把异常贴出来
[解决办法]
org.springframework.web.struts.DelegatingActionProxy 是spring的东西,应该没题吧。



<form-bean name="giveForm" typ="give.form.GiveForm"/ > 
?????
为何不是type?


[解决办法]
在web.xml中配置监听器
用ContextLoaderListener初始化spring容器
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
用contextConfigLocation制定spring配置文件的位置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>

热点排行