1.怎么样动态调用action的方法:
Struts.xml中如下配置
<action name="practicedbdelete" class="com.dream.FileClasses.PracticeAction" method="deleteInfor">
<result name="success">/success.jsp</result>
<result name="error">/fail.jsp</result>
</action>
method属性写好方法就可以了
2.action中引用request,respond
方法一、通过ServletActionContext类直接获取:
public String delete() throws Exception{
HttpServletRequest request = ServletActionContext.getRequest();
ServletContext servletContext = ServletActionContext.getServletContext();
request.getSession();
HttpServletResponse response = ServletActionContext.getResponse();
return "scope";
}
方法二、实现指定接口,由struts框架运行时注入:
public class myAction implements ServletRequestAware, ServletResponseAware, ServletContextAware{
private HttpServletRequest request;
private ServletContext servletContext;
private HttpServletResponse response;
public void setServletRequest(HttpServletRequest request) {
this.request=request;
}
public void setServletResponse(HttpServletResponse response) {
this.response=response;
}
public void setServletContext(ServletContext servletContext) {
this.servletContext=servletContext;
}
}
3.字符串按特定字符分化
String[] list=info.split("/");
按/分