rege.jsp页面
============

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
 
<html> 
<head>
<title>JSP for RegeForm form</title>
</head>
<body>
<html:form action="/rege">
password : <html:text property="password"/><html:errors property="password"/><br/>
username : <html:text property="username"/><html:errors property="username"/><br/>
<html:submit/><html:cancel/>
</html:form>
</body>
</html>
=======================================================================================================================
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">
  <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>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
=========================================================================================================================
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="regeForm" type="com.yd.struts.form.RegeForm" />  </form-beans>  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action 
    attribute="regeForm"
    input="/rege.jsp"
    name="regeForm"
    path="/rege"
    scope="request"
    type="org.springframework.web.struts.DelegatingActionProxy">
    <forward name="error" path="/error.jsp" />
    <forward name="success" path="/SUCCESS.jsp" /> 
    </action>  </action-mappings>    <message-resources parameter="com.yd.struts.ApplicationResources" />
   <message-resources parameter="cn.onlysoft.book.BookResources" />   
  <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
  <!--  <set-property property="contextConfigLocation" value="WEB-INF/applicationContext.xml"/>-->
  <set-property property="contextConfigLocation" value="WEB-INF/applicationContext.xml"/>
  </plug-in>
</struts-config>=================================================================================================================================
spring配置文件application.xml
============================
<?xml version="1.0" encoding="UTF-8"?>
<!--   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">
-->
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans>  <bean id="Userimp" class="com.dy.imp.Userimp">
<property name="sessionFactory">
<ref  bean="sessionFactory"/>
</property>
</bean>
  <bean name="/rege" class="com.yd.struts.action.RegeAction" singleton="false">   
   <property name="user">
   <ref bean="Userimp"/>
   </property>
  </bean>
  <bean id="dd" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
   <property name="driverClassName"
   value="com.microsoft.jdbc.sqlserver.SQLServerDriver">
   </property>
   <property name="url"
   value="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=wave;">
   </property>
   <property name="username" value="sa"></property>
   <property name="password" value="sa"></property>
  </bean>
  <bean id="sessionFactory"
   class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="dataSource">
   <ref bean="dd" />
   </property>
   <property name="hibernateProperties">
   <props>
   <prop key="hibernate.dialect">
   org.hibernate.dialect.SQLServerDialect
   </prop>
   </props>
   </property>
   <property name="mappingResources">
   <list>
   <value>com/dy/pojo/Users.hbm.xml</value></list>
   </property></bean></beans>
===================================================================================================
=====================================================================================================
我把hiernate也整合在spring的配文件里。
当我运行....http://127.0.0.1:8085/computer/rege.jsp
 rege.jsp这个页面可以出来
当我填入用户名与密码的时候
     点提交。。就现出
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我找了很久,配置文件检查了很久,由于我刚做SSH整合,还不是很清梦。。
请高手多多指点   

解决方案 »

  1.   

    404是找不到文件可能是FORM那里你写成“/rage”的问题。你写成“/rage.do”试试。因为既然你用STRUTS了。所有的请求都要经过STRUTS的SERVLET。试试吧。没有细看。要是还不行的话。就帮你再细看一下
      

  2.   

    <html:form action="<%=request.getContextPath()%>/rege.do"> 试一下呢
      

  3.   

    <html:form action=" <%=request.getContextPath()%>/rege.do"> ..这样报错了呢。。
    type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Exception in JSP: /rege.jsp:107:  <title>JSP for RegeForm form</title>
    8:  </head>
    9:  <body>
    10:   <html:form action=" <%=request.getContextPath()%>/rege.do"> 
    11: 
    12:  password : <html:text property="password"/><html:errors property="password"/><br/>
    13:  username : <html:text property="username"/><html:errors property="username"/><br/>
    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846
      

  4.   

    java.lang.NullPointerException
    org.apache.struts.config.impl.ModuleConfigImpl.findActionConfig(ModuleConfigImpl.java:332)
    报了这个错误。。
      

  5.   

    ACTION是这样的/*
     * Generated by MyEclipse Struts
     * Template path: templates/java/JavaClass.vtl
     */
    package com.yd.struts.action;import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;import com.dy.inft.UserInft;
    import com.yd.struts.form.RegeForm;/** 
     * MyEclipse Struts
     * Creation date: 10-04-2008
     * 
     * XDoclet definition:
     * @struts.action path="/rege" name="regeForm" input="/rege.jsp" scope="request" validate="true"
     * @struts.action-forward name="error" path="/error.jsp"
     * @struts.action-forward name="success" path="/SUCCESS.jsp"
     */
    public class RegeAction extends Action {
    UserInft user;
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    RegeForm rfm = (RegeForm) form;// TODO Auto-generated method stub
    System.out.println(""+rfm.getUsername()+"--"+rfm.getPassword());
    if (user.Add(rfm.getUsername(), rfm.getPassword()))
    {
    System.out.println("11111");
    return mapping.findForward("success");
    }
    return mapping.findForward("error");
    }
    public void setUser(UserInft user) {
    this.user = user;
    }
    }
      

  6.   

    有可能是标签引用的问题:
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%> 你用项目中的标签tld,尝试一下。
      

  7.   

    <set-property property="contextConfigLocation" value="WEB-INF/applicationContext.xml"/> ContextConfigLocation
      

  8.   

    估计是 需要 log4j 日志文件