質問

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>
役に立ちましたか?

解決

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

他のヒント

".do" is a action extension. You configure it in servlet mapping. When struts parses the url it's looking for such extension to distinguish static calls from the struts action. Then finds the mapping that correspond that URL but without ".do ". However, you have still specify ".do" in the forwards if your application configured to use that extension. Nowadays, this extension has less meaning as before. The URL rewrite technique brings to completely ignore that extension. With

<servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>/c/*</url-pattern>
</servlet-mapping>

and reference above you could completely dismiss it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top