初学struts 有一个问题没弄明白,就是关于如何把请求转交到action servlet处理,以下具体说一下:
在web.xml中定义的映射规则是
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
(好像这种形式比较安全)
而在实际的页面中的一个请求是这样的:
<html:form [color=red]action="/adminCpasswd">[/color]
<html:hidden property="action"/>
<tr>
<td height="18" bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="5" cellspacing="0">
......(中间略,太长了)
<tr>
<td height="18" bgcolor="#FFFFFF">
<html:submit styleClass="BUTTN-FIX1"><bean:message key="bbscs.botton.submit"/></html:submit>
<html:reset styleClass="BUTTN-FIX1"><bean:message key="bbscs.botton.reset"/></html:reset>
</td>
</tr>
</html:form>
在struts-config.xml中的action-mappings如下:
<action-mappings>
...(前后略)
<action input="admin.cpasswd" name="adminCpaswdForm" [color=red]path="/adminCpasswd"[/color] scope="request" type="com.laoer.bbscs.web.action.AdminCpasswd" validate="true">
<forward name="admincpasswd" path="admin.cpasswd" />
</action>
...
</action-mappings>
问题就是既然在web.xml中的定义的映射规则是以.do结尾的请求才会交给action servlet处理,而我看到的往往都是上面这种形式的的action(如上面的action="/adminCpasswd"),并没有以.do结尾,却也能交给它处理,这是怎么事,要是这样也能处理,那不是几乎所有的相对路径形式的请求都会交到struts的action servlet去处理,那上web.xml中的映射定义不是没起到作用,能不能帮忙解释一下,到底什么样的请求会转交到struts去处理,谢谢!
在web.xml中定义的映射规则是
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
(好像这种形式比较安全)
而在实际的页面中的一个请求是这样的:
<html:form [color=red]action="/adminCpasswd">[/color]
<html:hidden property="action"/>
<tr>
<td height="18" bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="5" cellspacing="0">
......(中间略,太长了)
<tr>
<td height="18" bgcolor="#FFFFFF">
<html:submit styleClass="BUTTN-FIX1"><bean:message key="bbscs.botton.submit"/></html:submit>
<html:reset styleClass="BUTTN-FIX1"><bean:message key="bbscs.botton.reset"/></html:reset>
</td>
</tr>
</html:form>
在struts-config.xml中的action-mappings如下:
<action-mappings>
...(前后略)
<action input="admin.cpasswd" name="adminCpaswdForm" [color=red]path="/adminCpasswd"[/color] scope="request" type="com.laoer.bbscs.web.action.AdminCpasswd" validate="true">
<forward name="admincpasswd" path="admin.cpasswd" />
</action>
...
</action-mappings>
问题就是既然在web.xml中的定义的映射规则是以.do结尾的请求才会交给action servlet处理,而我看到的往往都是上面这种形式的的action(如上面的action="/adminCpasswd"),并没有以.do结尾,却也能交给它处理,这是怎么事,要是这样也能处理,那不是几乎所有的相对路径形式的请求都会交到struts的action servlet去处理,那上web.xml中的映射定义不是没起到作用,能不能帮忙解释一下,到底什么样的请求会转交到struts去处理,谢谢!