当前位置:百问九>生活百科>action类 一定要使用 actionsupport类吗

action类 一定要使用 actionsupport类吗

2023-04-13 04:31:09 编辑:zane 浏览量:614

action类 一定要使用 actionsupport类吗

因为ActionSupport是你整合了Spring之后用的败模,再Spring的包里,光用Struts2的话,Action是不用继续任何东西的,不过一般都会有一个baseaction,让你的action都去继承这个东西,里面带了点你比较常用的对象public class BaseAction implements Serializable,RequestAware,SessionAware,ApplicationAware,ServletRequestAware,ServletResponseAware,ServletContextAware{private static final long serialVersionUID = -8737956568774373323L;protected Map request;protected Map session;protected Map application;protected HttpServletRequest httpServletRequest;protected HttpServletResponse httpServletResponse;protected HttpSession httpSession;protected ServletContext httpApplication;public void setSession(Map session) {this.session = session;}public void setRequest(Map request) {this.request = request;}public void setApplication(Map application) {this.application = application;}public void setServletRequest(HttpServletRequest httpServletRequest) {this.httpServletRequest = httpServletRequest;this.httpSession = httpServletRequest.getSession();}public void setServletResponse(HttpServletResponse httpServletResponse) {this.httpServletResponse = httpServletResponse;}public void setServletContext(ServletContext servletContext) {this.httpApplication = servletContext;}public String execute() throws Exception{return "success";}}追问:但是,我查到ActionSupport的源码包是X-WORK里面的,按正常情况我可以调用的吧。另外我之前都可以直接导猜枯羡入的,只是不懂昨晚为什么就不行了追答:你用的x-work整合的啊,那个不熟,穗拍你用的myeclipse的话,按ctrl+shift+o可以控制在多个包的情况下,选择包的导入吧

版权声明:文章由 百问九 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.baiwen9.com/life/139767.html
热门文章
二维码