用SSH写了一个简单的登录系统,但运行时一直报Servlet action is not available错误,调试三天了,在GOOGLE,BAIDU里也搜了下,还是没能解决,是不是配置上的问题呢,敬请高手指点.
--web.xml文件
<?xml version="1.0" encoding="GBK"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<filter>
<filter-name>requestContextFilter</filter-name>
<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>requestContextFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.ssh.action.base.MyActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!--struts标签-->
<jsp-config>
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>--struts-config.xml文件
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="userLoginForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="name" type="java.lang.String"/>
<form-property name="pass" type="java.lang.String"/>
</form-bean>
</form-beans>
<global-exceptions>
<exception key="userException"
type="org.ssh.exception.SshException"
scope="request"
path="/WEB-INF/jsp/error.jsp"></exception>
<exception key="otherException"
type="java.lang.Exception"
scope="request"
path="/WEB-INF/jsp/error.jsp"></exception>
</global-exceptions>
<global-forwards>
<forward name="user" path="/WEB-INF/jsp/login.jsp"/>
</global-forwards>
<action-mappings>
<action path="/user" forward="WEB-INF/jsp/login.jsp" />
<action path="/userLogin" name="userLoginForm"
scope="request" validate="false">
<forward name="success" path="/WEB-INF/jsp/showLonginInfo.jsp"></forward>
<forward name="failure" path="/WEB-INF/jsp/login.jsp"></forward>
</action>
</action-mappings>
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"></controller>
<message-resources parameter="message"></message-resources>
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/actionContext.xml,/WEB-INF/appContext.xml,/WEB-INF/daoContext.xml"/>
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
<set-property property="stopOnFirstError" value="true"/>
</plug-in>
</struts-config>
--web.xml文件
<?xml version="1.0" encoding="GBK"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<filter>
<filter-name>requestContextFilter</filter-name>
<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>requestContextFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.ssh.action.base.MyActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!--struts标签-->
<jsp-config>
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>--struts-config.xml文件
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="userLoginForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="name" type="java.lang.String"/>
<form-property name="pass" type="java.lang.String"/>
</form-bean>
</form-beans>
<global-exceptions>
<exception key="userException"
type="org.ssh.exception.SshException"
scope="request"
path="/WEB-INF/jsp/error.jsp"></exception>
<exception key="otherException"
type="java.lang.Exception"
scope="request"
path="/WEB-INF/jsp/error.jsp"></exception>
</global-exceptions>
<global-forwards>
<forward name="user" path="/WEB-INF/jsp/login.jsp"/>
</global-forwards>
<action-mappings>
<action path="/user" forward="WEB-INF/jsp/login.jsp" />
<action path="/userLogin" name="userLoginForm"
scope="request" validate="false">
<forward name="success" path="/WEB-INF/jsp/showLonginInfo.jsp"></forward>
<forward name="failure" path="/WEB-INF/jsp/login.jsp"></forward>
</action>
</action-mappings>
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"></controller>
<message-resources parameter="message"></message-resources>
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/actionContext.xml,/WEB-INF/appContext.xml,/WEB-INF/daoContext.xml"/>
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
<set-property property="stopOnFirstError" value="true"/>
</plug-in>
</struts-config>
解决方案 »
- jsp从缓存读图片的问题
- table tbody tr td 怎么添加自定义属性?
- logic:iterate 数据就迭代一半,后面的数据报NULLPOINTEREXCEPTION
- webwork里有没有这样的转化类,对特殊字符,比如空格转化成%20这样的。
- 配置连接orcale9i(新手上路,见笑)
- 请教一个页面控制的问题
- 请教:webapps\ROOT下有一目录test
- rohn(土豆丝)来拿分
- 如何使用JSP远程编译一个Java类?
- ssm简单配置,浏览器请求404怎么回事,正常要的效果是返回后台数据
- 在一个表格中出现多台设备信息,如何做到?
- 将JAVA工程转为C++工程<polliwog>
楼主【xuxin_xjb】截止到2008-07-28 11:04:56的历史汇总数据(不包括此帖):
发帖的总数量:2 发帖的总分数:20 每贴平均分数:10
回帖的总数量:2 得分贴总数量:2 回帖的得分率:100%
结贴的总数量:2 结贴的总分数:20
无满意结贴数:1 无满意结贴分:20
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:50.00 % 无满意结分率:100.00%
敬礼!
<?xml version="1.0" encoding="GBK"?>
<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.xsd">
<bean name="actionTemplate" abstract="true">
<property name="myService" ref="myService"/>
</bean> <!-- 处理管理员登录 -->
<bean name="/userLogin" class="org.ssh.action.UserLoginAction" scope="prototype" parent="actionTemplate"/>
<!-- 处理添加学生 -->
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>/userLogin</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>authorityInterceptor</value>
</list>
</property>
</bean> <bean id="authorityInterceptor" class="org.yeeku.action.authority.AuthorityInterceptor"/>
</beans>appContext.xml--配置数据源,sessionFactory和事务<?xml version="1.0" encoding="GBK"?>
<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.xsd"> <!-- 定义数据源Bean,使用C3P0数据源实现 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost/sshtest"></property>
<property name="user" value="root"></property>
<property name="password" value="mysql"></property>
<property name="maxPoolSize" value="40"></property>
<property name="minPoolSize" value="1"></property>
<property name="initiaPoolSize" value="1"></property>
<property name="maxIdleTime" value="20"></property>
</bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="mappingResources">
<list>
<value>User.hbm.xml</value>
<value>Things.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.jdbc.batch_size">20</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sesseionFactory" ref="sessionFactory"></property>
</bean>
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager"></property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!-- 定义业务逻辑处理组件 -->
<bean id="MyService" class="org.ssh.service.impl.MyServiceImpl">
<property name="userDao" ref="userDao"/>
</bean> <!-- 定义BeanNameAutoProxyCreator -->
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<!-- 指定对满足哪些Bean name的Bean自动生成业务代理 -->
<property name="beanNames">
<!-- 下面是所有需要自动创建事务代理的Bean-->
<list>
<value>MyService</value>
</list>
<!-- 此处可增加其他需要自动创建事务代理的Bean-->
</property>
<!-- 下面定义BeanNameAutoProxyCreator所需的事务拦截器-->
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
<!-- 此处可增加其他新的Interceptor -->
</list>
</property>
</bean>
</beans>
看看是不是这写错了啊,我以前也碰到过类似的情况,那是因为我的配置文件写错了,以致于servlet不能够请求
你好好看看你的配置文件