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

SSH配置,该怎么处理

2012-01-23 
SSH配置有SSH方面的高手吗?我原来有个工程1是SSH做的,后来新建一工程,先做了个登陆,还用SSH,我按照工程1的

SSH配置
有SSH方面的高手吗?我原来有个工程1是SSH做的,后来新建一工程,先做了个登陆,还用SSH,我按照工程1的配置写,开始配struts,没连数据库,只是判断特值可以登陆成功,然后配Spring+hibenate,开始web.xml中没配<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
< stener-class>
< stener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>,index.jsp可以打开,提交后报No wedapplicatontext,就是说找不到资源文件,配上这后,就报404了,这是什么问题呢
附上我的三个xml文件
web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <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>
  <listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
  <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

struts-config.xml
<struts-config>
  <data-sources />
  <form-beans>
  <!--登陆Form -->
  <form-bean name="loginForm" type="webexp.form.LoginForm" />
  </form-beans>
  <global-exceptions />
  <global-forwards />
  <action-mappings>
  <!--登陆 -->
  <action path="/login" name="loginForm" scope="request" type="webexp.action.LoginAction">
  <forward name="success" path="/main.jsp"/>
  <forward name="fail" path="/login.jsp"/>
  </action>
  </action-mappings>
  <controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />
  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>


applicationContext.xml
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">


<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"


value="classpath:hibernate.cfg.xml">
</property>
<property name="mappingResources">
<list>

<value>webexp/mapping/Operator.hbm.xml</value>

</list>
</property>

</bean>

<bean id="operdao" class="webexp.dao.OperatorDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="operser"
class="webexp.service.OperatorService">
<property name="operDao" ref="operdao"></property>
</bean>
<bean name="/login" class="webexp.action.LoginAction">
<property name="operSer" ref="operser"></property>

</bean>

<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
</beans>


[解决办法]
呵呵 你把web-xml中这句

<listener> 
<listener-class> 
org.springframework.web.context.ContextLoaderListener 
</listener-class> 
</listener> 
<context-param> 
<param-name>contextConfigLocation </param-name> 
<param-value>classpath:applicationContext.xml </param-value> 
</context-param>

换成这样试下:
<context-param> 
<param-name>contextConfigLocation </param-name> 
<param-value>classpath:applicationContext.xml </param-value> 
</context-param>
<listener> 
<listener-class> 
org.springframework.web.context.ContextLoaderListener 
</listener-class> 
</listener>
[解决办法]
HTTP 404 Error 总结起来就一句话:资源找不到!
楼主最好详细看看到底是哪个环节报的404!
[解决办法]
struts-config中的错误
<action path="/login" name="loginForm" scope="request" type="webexp.action.LoginAction"> 

<action path="/login" name="loginForm" scope="request" type="org.springframework.web.struts.DelegatingActionProxy"> 

在。web.xml中只要加这几句代码就可以了
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
  
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

在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>

<!-- WEBUI -->

<bean name="/user" class="com.web.action.OrderAction">
<property name="userService" ref="userService" />
</bean>

<!-- BIZ -->
<bean id="userService" parent="serviceTemplate">
<property name="target" ref="userServiceTarget" />
</bean>

<bean id="serviceTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">


<property name="transactionManager" ref="txManager" />
<property name="transactionAttributes">
<props>
<prop key="a*">PROPAGATION_REQUIRED</prop>
<prop key="d*">PROPAGATION_REQUIRED</prop>
<prop key="u*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_SUPPORTS,readOnly</prop>
</props>
</property>
</bean>

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

<bean id="userServiceTarget" class="com.biz.userService">
<property name="userDao" ref="userDao" />
</bean>
<!-- DAO -->
<bean id="userDao" class="com.dao.userOrderDao">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>

</beans>
[解决办法]
我上传了个基础配置 去看看吧
http://download.csdn.net/source/649512

热点排行