日期:2014-05-18  浏览次数:20838 次

关于struts中的问题
比如超级连接是这样的
<a   herf= "aaaaa.do "> </a>


我想让用户点击这个以后
我的一个action这个中的一个方法开始执行,这个需要怎么写?

------解决方案--------------------
dispatchAction啊,***.do?method=方法名&参数=
------解决方案--------------------
public xxxxAction extends DispatchAction{
public ActionForward methodName(
ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse)
throws Exception {
......
}
}

在struts-config.xml中
<action parameter= "method " path= "/package/loginAction " type= "package.xxxxxxAction " validate= "false " >
<forward ..../>
</action>

jsp页面
<html:form action= "/package/loginAction.do?method=methodName&paramter=xxxxxx " method= "post "> ...
</html:form>

------解决方案--------------------
struts-config.xml
<action path= "/saveSubscription "
type= "org.apache.struts.actions.DispatchAction "
name= "subscriptionForm " scope= "request " input= "/subscription.jsp "
parameter= "method "/>
parameter的属性值是可以任意起的,只要你记得在传参数的时候统一就可以了。比如我写了一个类似这样的Action,它继承自DispatchAction类,包含了三个操作方法,有Add(),Update(),Delete()。当我想要调用这个Action的Update操作时,提交的URL应该类似这样的:
http://localhost:8080/myapp/saveSubscription.do?method=update