Home  >  Article  >  Java  >  A simple case of configuring java Struts2

A simple case of configuring java Struts2

Y2J
Y2JOriginal
2017-05-03 14:24:37993browse

This article mainly introduces the configuration and simple cases of java Struts2. Friends who need it can refer to the configuration and simple cases of

Struts2:

1. Create a dynamic web project (let it automatically generate the web.xml file when creating)

2. Introduce relevant jar packages

3. Configure in web.xml

(The first file loaded after starting the tomcat server is web.xml)

Add in the configuration Filter:


struts2
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter


struts2
/*

4. Create the core file of struts (struts.xml) and create it in the Java Resources-src file directory with the content:




5. Also create an Action class in the Java Resources-src file directory, inherit from ActionSupport, and override the execute method in the parent class:

public class HelloWorldAction extends ActionSupport {
@Override
public String execute() throws Exception {
System.out.println("执行Action");
return SUCCESS;
}
}

6. In struts.xml, 6630c188dbdc50abaf38baed4eae10df tag:




/result.jsp


7. Create a view (create result.jsp in the WebRoot directory):


This is result.jsp!

8. Debugging Run

The above is the detailed content of A simple case of configuring java Struts2. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn