The MyEclipse integrated development environment is used here.
(1) Installation MyEclipse 8.5
(2) Installation configuration Tomcat6.0
- Download apache-tomcat-6.0.18
- Start MyEclipse 8.5, click the window->preferences command, and select the myeclipse->servers->tomcat->tomcat6.x option, as shown in:
Click the browse button behind the Tomcat home directory to find the Tomcat folder you downloaded, and when the settings are complete, click the OK button.
(3) Create a simple Struts 2 program
- Create a Web project
- Add a struts jar package to a project
3. Create a struts. XML configuration file
-
- to make the modified code for the default Web. xml file, Web. XML is required, and the other configuration files are optional, which is the core configuration file that is used to deploy the entire project. For the Struts 2 framework, if you want to load the controller filterdispatcher, you need to configure Filterdispatcher
- Configure the Struts.xml file, which is a very important core profile in the Struts application, struts 2 framework controls when to process which program and how to handle it based on the Struts.xml configuration file
-
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.1//en" "http://struts.apache.org/dtds/ Struts-2.1.dtd "><struts> <constant name=" Struts.devmode "value=" true "/> <package name=" struts2_ Ognl_demo "extends=" Struts-default "> <!--defining Interceptors--<interceptors> <interceptor name=" hell Oworld "class=" com. Helloworldinterceptor "/> </interceptors> <action name=" test "class=" com. Myaction "> <result>success.jsp</result> <!--action to reference interceptors--<in Terceptor-ref name= "HelloWorld"/> <interceptor-ref name= "Defaultstack"/> </action></p ackage></struts>
6. Create an action business controller
7. Create a JSP view page
- Summary:
- Load configuration required to join Struts 2 in Web. xml
- The Execute () method of the action is used to return a string
Building a Struts 2 working environment