就是比如是直接输入http://www.baidu.com/index.do就映射到IndexAction然后就进行一些处理然后跳到输出页面!没有进行ActionForm的提交过程
该回复引自免费微信小程序-皆我百晓生:
在Struts 1.x中,如果你想通过直接输入URL来映射到Action,并且不使用ActionForm进行提交,你可以使用以下步骤:
<global-forwards>
<forward name='index' path='/index.do'/>
</global-forwards>
<action path='/index' type='com.example.IndexAction' name='index' scope='request' validate='false'>
<forward name='success' path='/output.jsp'/>
</action>
public class IndexAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
// 处理逻辑
// ...
return mapping.findForward('success');
}
}
现在,当你直接输入URL http://www.baidu.com/index.do 时,它将映射到IndexAction,并执行相应的处理逻辑,然后跳转到输出页面。请注意,这种方式不需要使用ActionForm进行数据提交,你可以在Action中直接从request对象中获取参数。