struts的DevMode模式

一、如下修改:

<constant name="struts.devMode" value="true" />

这段代码有可能没有效果,解决办法:

<constant name="struts.configuration.xml.reload" value="true"/>

 二、struts2中的action配置里没有class属性他会如何执行

在没有配置class的时候,默认执行ActionSupport类,该类里边有一个execute()方法,该方法返回success。

<result>不配置name的时候默认就是success

三、Action的三种写法

public class IndexAction1{
   public String execute(){
        return "success";
    }       
}

public class IndexAction1 implements Action{
   public String execute(){
         return "success";
    }       
}

public class IndexAction1 extends ActionSupport{
   public String execute(){
         return "success";
    }       
}

 四、struts2中的路径问题是根据action的路径而不是JSP路径来确定的,所以尽量不要使用相对路径。

在 jsp 文件中可以这样写来统一路径:

<%

String contextPath=request.getContextPath();

String basePath=requset.getScheme()+"://"+requset.getServerName()+":"+request.getServerPort()+path+"/";

%> 

五、通过action元素的method属性来制定Action执行时调用的方法。

原文地址:https://www.cnblogs.com/lyjs/p/4959164.html