Search code examples
javastrutsstruts-configstruts-action

what is the differance path type in java struts.xml?


I am new java struts framework. But I want to ask a question.

In struts.xml path is .do like "/AddReq.do" OR path is only name like "AddReq"

What is difference between "/AddReq.do" and "AddReq" ?

For example

<action path="/AddReqPage"
type="...actions.AddReqPageAction">
        <forward name="success" path="AddReq" /> 
        <forward name="failure" path="/bos.jsp" />
</action>
<action path="/AddReq"
type="...actions.AddReqAction"
name="AddReqForm" validate="true"
scope="request">
        <forward name="success" path="/AddReqDetail.do" />
        <forward name="hata" path="AddReq" />
        <forward name="failure" path="/bos.jsp" />
</action>

Solution

  • Not much difference. Both should work - provided you map to struts ActionServlet correctly in your web.xml.

    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    

    Conventionally, struts uses *.do pattern to distingush its servlet from other servlets and JSPs