哭啊!!!怎么都出不来。请高手看看,解决了,再加分!!!!!
一在页面提交,就出错 struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<data-sources />
<form-beans >
<form-bean name="userForm" type="com.yu.znt.struts.form.UserForm" />
</form-beans> <global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="userForm"
input="/jsp/errors.jsp"
name="userForm"
parameter="status"
path="/jsp/user"
scope="request"
type="com.yu.znt.struts.action.UserAction">
<forward name="registersuccess" path="/jsp/index.jsp"></forward>
<forward name="registerfail" path="/jsp/register.jsp"></forward>
</action> </action-mappings>
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"></controller>
<message-resources parameter="com.yu.znt.struts.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="WEB-INF/classes/applicationContext.xml" />
</plug-in>
</struts-config>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>encoding</filter-name>
<filter-class>com.yu.znt.filter.EncodingFilter</filter-class>
<init-param>
<param-name>charset</param-name>
<param-value>gbk</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
</servlet>
<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>
</web-app>
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 id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java.comp/env/jdbc/mldn</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>
<!-- 表示允许自动提交 -->
<prop key="hibernate.connection.autocommit">true</prop>
<!-- 表示显示sql语句 -->
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/yu/znt/model/User.hbm.xml</value></list>
</property></bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="iuserdao" class="com.yu.znt.dao.IUserDAO" abstract="false"></bean>
<bean id="iuserdaoimpl" class="com.yu.znt.dao.impl.IUserDAOImpl" parent="iuserdao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
</beans>
页面提交代码
<html:form action="jsp/user.do" method="post">
用户ID:<html:text property="userid"></html:text><br>
用户密码:<html:password property="userpwd"></html:password><br>
确认密码:<html:password property="confirmpwd"></html:password><br>
丢失密码问题:<html:text property="userques"></html:text><br>
丢失密码问题答案:<html:text property="userans"></html:text><br>
验证码:<html:text property="checkcode"></html:text><img src="image.jsp"><br>
<input type="hidden" name="status" value="register">
<input type="hidden" name="type" value="1">
<html:submit>提交</html:submit>
<html:reset>重置</html:reset></html:form>
出错代码
HTTP Status 404 - Servlet action is not available--------------------------------------------------------------------------------type Status reportmessage Servlet action is not availabledescription The requested resource (Servlet action is not available) is not available.
--------------------------------------------------------------------------------Apache Tomcat/5.5.23
一在页面提交,就出错 struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<data-sources />
<form-beans >
<form-bean name="userForm" type="com.yu.znt.struts.form.UserForm" />
</form-beans> <global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="userForm"
input="/jsp/errors.jsp"
name="userForm"
parameter="status"
path="/jsp/user"
scope="request"
type="com.yu.znt.struts.action.UserAction">
<forward name="registersuccess" path="/jsp/index.jsp"></forward>
<forward name="registerfail" path="/jsp/register.jsp"></forward>
</action> </action-mappings>
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"></controller>
<message-resources parameter="com.yu.znt.struts.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="WEB-INF/classes/applicationContext.xml" />
</plug-in>
</struts-config>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>encoding</filter-name>
<filter-class>com.yu.znt.filter.EncodingFilter</filter-class>
<init-param>
<param-name>charset</param-name>
<param-value>gbk</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
</servlet>
<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>
</web-app>
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 id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java.comp/env/jdbc/mldn</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>
<!-- 表示允许自动提交 -->
<prop key="hibernate.connection.autocommit">true</prop>
<!-- 表示显示sql语句 -->
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/yu/znt/model/User.hbm.xml</value></list>
</property></bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="iuserdao" class="com.yu.znt.dao.IUserDAO" abstract="false"></bean>
<bean id="iuserdaoimpl" class="com.yu.znt.dao.impl.IUserDAOImpl" parent="iuserdao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
</beans>
页面提交代码
<html:form action="jsp/user.do" method="post">
用户ID:<html:text property="userid"></html:text><br>
用户密码:<html:password property="userpwd"></html:password><br>
确认密码:<html:password property="confirmpwd"></html:password><br>
丢失密码问题:<html:text property="userques"></html:text><br>
丢失密码问题答案:<html:text property="userans"></html:text><br>
验证码:<html:text property="checkcode"></html:text><img src="image.jsp"><br>
<input type="hidden" name="status" value="register">
<input type="hidden" name="type" value="1">
<html:submit>提交</html:submit>
<html:reset>重置</html:reset></html:form>
出错代码
HTTP Status 404 - Servlet action is not available--------------------------------------------------------------------------------type Status reportmessage Servlet action is not availabledescription The requested resource (Servlet action is not available) is not available.
--------------------------------------------------------------------------------Apache Tomcat/5.5.23
可修改如下:
1,<action-mappings >
<action
attribute="userForm"
input="/errors.jsp"
name="userForm"
parameter="status"
path="/user"
scope="request"
type="com.yu.znt.struts.action.UserAction">
<forward name="registersuccess" path="/jsp/index.jsp"></forward>
<forward name="registerfail" path="/jsp/register.jsp"></forward>
</action>
即是把/jsp去掉;
2,<html:form action="user.do" method="post">
用户ID:<html:text property="userid"></html:text><br>
用户密码:<html:password property="userpwd"></html:password><br>
确认密码:<html:password property="confirmpwd"></html:password><br>
丢失密码问题:<html:text property="userques"></html:text><br>
丢失密码问题答案:<html:text property="userans"></html:text><br>
验证码:<html:text property="checkcode"></html:text><img src="image.jsp"><br>
<input type="hidden" name="status" value="register">
<input type="hidden" name="type" value="1">
<html:submit>提交</html:submit>
<html:reset>重置</html:reset></html:form>
即修改为action="user.do"
3,建议楼主把jsp这个目录去掉,相关jsp文件放到根目录下即可。struts-config.xml里的path也别加/jsp!这样再试试!
页面提交代码
HTML code
<html:form action="/jsp/user.do" method="post">
用户ID:<html:text property="userid"></html:text><br>
用户密码:<html:password property="userpwd"></html:password><br>
确认密码:<html:password property="confirmpwd"></html:password><br>
丢失密码问题:<html:text property="userques"></html:text><br>
丢失密码问题答案:<html:text property="userans"></html:text><br>
验证码:<html:text property="checkcode"></html:text><img src="image.jsp"><br>
<input type="hidden" name="status" value="register">
<input type="hidden" name="type" value="1">
<html:submit>提交</html:submit>
<html:reset>重置</html:reset></html:form>即把action="/jsp/user.do"!先试这个哈,不行的话单M我!
出来 看看,前几天刚刚做了一个ssh的小项目~你的问题应该不是楼上说的问题。
因为你的action 路径错了的话,在加载页面之时就错了。
不会出现 Servlet action is not available也是刚学的
刚开始我也是出现这个问题。我的是因为包的问题。要不你就是一个低级错误
我自学的时候,问题会很多呀,
还有一个no session or session was closed ,session no synchronization
要是你想要哪包的话。。请留邮箱
我不知道你最后加什么包了?但是我的一直都不可以,hibernate-annotation的包我也删了,也不行。把别的可以运行的项目包加上也不行。
我想路径应该不会错吧?因为我请求的页面在项目的jsp目录下
|-webroot
|-jsp
|-register.jsp
是这样的用打印方法除错,register.jsp页面没错。debug或者在action中打印响应时,完全接不到页面的响应。这是我userAction的部分内容,应该没错吧?public class UserAction extends DispatchAction {
//注入方法
private IUserDAO iUserDAO;
/*
* Generated Methods
*/ /**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward validate(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = (UserForm) form;
ActionErrors errors = new ActionErrors();
if(userForm.getType() == 1){
..........
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="WEB-INF/classes/applicationContext.xml" />
</plug-in>这里加载的时候有问题,还请高手回答为什么这里会出错呢? 应该把这个插件放在web.xml内加载 <servlet>
<servlet-name>contextLoder</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>这样就解决冲突了。
请高手说明一下这是为什么?
http://blog.csdn.net/gwt600/archive/2006/11/13/1381953.aspx