Recently, I encountered a small requirement. I want to set the resultType returned by some actions to freemarker by default. I first wanted to configure the global result on the action, and then use an expression for the name, and then type = "freemarker ", however, after the experiment, we found that the configuration was not successful because it was instantiated when struts2 was started, and then the expression could not be used in the action, and an exception was reported. so I tracked the source code and found the relevant code [java] public String getFullDefaultResultType () {if (defaultResultType = null) IN THE PackageConfig class )&&! Parents. isEmpty () {for (PackageConfig parent: parents) {String parentDefault = parent. getFullDefaultResultType (); if (parentDefault! = Null) {return parentDefault ;}} return defaultResultType;} This is a recursive query. If this package is not configured, the parent package is searched and the default-package is found, this parameter is specified as dispatcher. okay, the code is found. How can I change it, you only need to re-declare the result-type [html] <result-type name = "freemarker" class = "org. apache. struts2.views. freemarker. freemarkerResult "default =" true "/> and set it to default. When this package is parsed, it is set to the default result-type. the related code is in com. opensymphony. xwork2.config. providers. xmlequalatio In the addResultTypes method of the nProvider class. [java] protected void addResultTypes (PackageConfig. builder packageContext, Element element) {NodeList resultTypeList = element. getElementsByTagName ("result-type"); for (int I = 0; I <resultTypeList. getLength (); I ++) {Element resultTypeElement = (Element) resultTypeList. item (I); String name = resultTypeElement. getAttribute ("name"); String className = resultTypeElemen T. getAttribute ("class"); String def = resultTypeElement. getAttribute ("default"); Location loc = DomHelper. getLocationObject (resultTypeElement); Class clazz = verifyResultType (className, loc); if (clazz! = Null) {String paramName = null; try {paramName = (String) clazz. getField ("DEFAULT_PARAM "). get (null);} catch (Throwable t) {// if we get here, the result type doesn't have a default param defined .} resultTypeConfig. builder resultType = new ResultTypeConfig. builder (name, className ). defaultResultParam (paramName ). location (DomHelper. getLocationObject (resultTypeElement); Map <String, String> para MS = XmlHelper. getParams (resultTypeElement); if (! Params. isEmpty () {resultType. addParams (params);} packageContext. addResultTypeConfig (resultType. build (); // set the default result type if ("true ". equals (def) {packageContext. defaultResultType (name) ;}}} this code is used to parse the struts2 configuration file and obtain the result-type element. Then, parse the related elements. If the default value is set to true, the result-type is set to the default value.