Struts2 implementation principle

1. Get the request path; (specific action)

2. Find struts.xml under src, use dom4j to parse the content in the xml file, and use the specific action value in the request path to match the value of the name attribute under the action tag in the xml.

3. Match the name attribute value, find the value of another attribute class in the action tag where you are, and get the full path of the action, and use reflection to implement the function;

(Reflection code:

Class clazz = Class.forName("action全路径");

//Get the method whose name is execute

Method m = clazz.getMethod("execute");

//Method execution

Object obj = m.invoke();

4. Get the return value in the action method. In the struts.xml file, whether the name attribute value of the result tag in the matching action tag is the same. If they are the same, jump to the configured page;

Guess you like

Origin blog.csdn.net/weixin_44182586/article/details/104127456