struts action 问题

来源:百度知道 编辑:UC知道 时间:2024/06/17 02:04:31
struts1能不能像struts2一样,将Action类中的每一个处理方法定义成一个逻辑Action,就是直接调用其method。
就像struts2配置文件中的method属性
<action name="abc" class="AbcAction" method="login"></action>
然后/abc.action一下就直接跑login方法去了。
struts1能吗?
那请问 puderty
url该怎么写呢?

是/XXXAction.do?method=login吗?

struts1中有DispathAction,你的Action只要是继承自这个类就可以了
然后
<action attribute="xxxForm" name="xxxForm" parameter="method" path="/xxx" scope="request"
type="com.xxxAction"> 你需要在jsp页面中写一个<input type="hidden" name="method" value="login">就可以了
还有对应的FormBean中要写一个
private String method;来获取表单中的method隐藏域,这样就能够自动执行那个叫做login的方法了,当然还可以有其他的方法,比如<input type="hidden" name="method" value="register">

能,继承dispatcherAction就可以,然后在配置文件中定义parameter,如果parameter定义为method,login.do?method=test就是调用login中的test方法

可以,用的action继承dispathaction类。

bu dong

当然可以