When learning dynamic method calls, the written link is <a href = "User/user! List "> Add students </a>
However, when you click the link, the following error message is displayed:
There is no Action mapped for namespace [/user] and action name [user! Add] associated with context path [/struts2_050_actionmethod]
After checking the document, we can see that struts2 can choose enable and disable for DMI for two reasons: 1) DMI may cause security problems; 2) DMI and wildcard method functions overlap.
However, by default, DMI is enable.
After carefully reading my configuration file, I found that when I copied other files, I copied such a sentence.
<Constant name = "struts. Enable. dynamicmethodinvocation" value = "false"/>
In this case, DMI is set to disable.
Delete this sentence, or change the value to "true" to get the expected result.
Add in struts. xml
<Constant name = "struts. Enable. dynamicmethodinvocation" value = "true"/>
Enable dynamic method call.
We recommend that you use wildcards to call dynamic methods. Do not use actionname! Methodname
.
Dynamic method calls in versions earlier than struts2 are enabled by default, but 2.3.15 is disabled by default.
Struts2 DMI cannot run