STRUTS2 first time use configuration and logging Hello-world

Source: Internet
Author: User

Environmental Description myeclipse7struts-2.3.14
Problem: Can't find action, let me have a headache a morning problem ah http Status 404-/struts2/hello.action

type Status Report

message /struts2/hello.action

Description The requested resource (/struts2/hello.action) is not available.


Read a lot about these explanations, but also in accordance with many blog written on the configuration, but still can not find, finally I look at the last 51cto inside a video, speak particularly detailed, according to what he did, will succeed, haha 51cto video address code download Project package:/HTTP download.csdn.net/detail/jianjian1992/8852069 Configuration Step 1.struts2 Download

http://archive.apache.org/dist/struts/binaries/

2. After download unzip will find an Apps folder, there are many war files, you can first hit Kaixie compression software, and then to extract them.
, decompression Struts2-blank, inside is actually a simple struts project, that is, demo example, we should use this demo to build our project!!! This is the point!! Creation of 3.WEB Engineering

Create a Web Project in MyEclipse, I'm named Struts2.

4.jar package import which jar packages are imported? Let's take a look at what's imported in Struts2-blank! Take a look at the path I opened!!
Then copy the jar packages and paste them in the project and copy them to the Web-inf Lib folder.
5.web.xml is still modified by reference to the demo example to open the Web. xml file inside the Web-inf.
The demo Web. XML is as follows, and we want to copy the contents of the green box to the project's Web. Xml.

The creation and modification of 6.struts.xml Struts.xml is required to be placed in the Web-inf/classes directory, so we find the Struts.xml in the demo directory, copy it, and paste it into the project's SRC folder.



After opening the project in the Struts.xml, the middle of <struts></struts> can be deleted, then you can add their own content!

The setting of the 7.struts DTD file (optional) This entry is intended to facilitate the writing of the following prompts in the XML file

Follow these steps to set up




Key is the path inside the Struts.xml, location selects the file System,key type to select INTO uri!


The path to location is as follows


That's it, okay, OK.


8. Write a very simple and simple action class in the SRC default package to write a class, only an execute function returns a "success" string.

9. Struts.xml for this action in the name of the action inside the name is after the form inside the call, class is the class name, there is no add bag, if said Testaction.java in bag bag inside, that will be written bag.testaction. Here the result is set to action return success string, then jump to welcome.jsp page
10.index.jsp and welcome.jsp page index.jsp inside is a form, simple to explode note the action inside the form is "test.action"

Welcome.jsp as follows:
11. Load the project, the server starts up I'm using MyEclipse's own tomcat,


And then run down,

12. Running Results


Then click a button, haha, finally run successfully, good fun ah!






Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

STRUTS2 First Use configuration and recording (graphic) Hello-world

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.