[Java] struts 2 getting started

abstract

This article is an introduction to struts 2 and a configuration tutorial. How to manually configure in intelj idea. When using idea to create a new struts 2 Web project, the download of the jar package failed. There is no way to manually download the jar package.

step

Copy it to the demo project of idea, as shown in the figure below

4. Add package reference file > project structure > Library >+

5. Struts-2.3 34\apps\struts2-blank\WEB-INF\classes\struts. Copy the XML file to the SRC directory of the project, as shown in the figure below

Keep the struts node and delete all its internal nodes.

6. Add package com. In SRC directory demo. Action and add the first action class

7. In Src / struts Add the following configuration to XML

Among them, extensions is commonly used struts default. Namespace: it is equivalent to the directory where the accessed action is located. If it is configured as / you can use / Hello Action access. If it is configured as / AAA, it needs to be accessed through / AAA / Hello Action.

8. Configure struts controller, that is, filter

9. Add test page in index JSP, jump to our hello action

Note that the El expression and JSP are used here. You need to add a package and add the one provided by Tomcat.

test

Jump

So far, our first struts 2 Web Application Demo has been successful.

So, hello Action must be Action?

Can we change it to something else, for example DD, as shown in the figure below:

Of course, you can also do without action

as follows

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>