1

ストラットを学習しようとしていますが、問題が発生しました。だからここにそれの長短があります:

  1. 私が遭遇している問題は、JSP送信ボタンをクリックすることです
  2. 適切なアクションが呼び出されます。
  3. アクションは Java クラスにジャンプし、適切な応答を作成します。
  4. 応答がアクションに返されます。
  5. レスポンスが元々 null でなかった場合、アクションは ActionForm の結果を null に設定します。

したがって、これまでのところ、2 番目のアクション タイプを作成したときに何らかの形で構成を台無しにしたか、Web xml アクション マッピングが正しくないことが推測されます。誰が間違っているのか教えてもらえますか?

struts-config.xml

<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
    <form-beans>
        <form-bean name="searchForm" type="com.agreen.struts.test.SearchForm" />
        <form-bean name="addForm" type="com.agreen.struts.test.AddEmployeeForm" />
    </form-beans>
    <global-forwards>
        <forward name="search" path="/search.jsp" redirect="false" />
        <forward name="addEmployee" path="/addEmployee.jsp" redirect="false" />
    </global-forwards>
    <action-mappings>
        <action path="/search"
            type="com.agreen.struts.test.SearchAction"
            name="searchForm"
            scope="request"
            validate="true"
            input="/search.jsp"></action>

        <action path="/addEmployee"
            type="com.agreen.struts.test.AddEmployeeAction"
            name="addForm"
            scope="request"
            validate="true"
            input="/addEmployee.jsp"></action>
    </action-mappings>
    <message-resources parameter="MessageResources" />
</struts-config>

web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
    <!-- Action Servlet Configuration-->
    <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>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <!-- Action Servlet Mapping -->
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <!-- The Welcome File List -->
    <welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
    </welcome-file-list>
</web-app>
4

0 に答える 0