Recently I think idea is a good Java development tool, so I tried to switch from myeclipse to idea. After I used it, I found that it was really good. The Code prompts and interfaces were quite good, so I used idea to develop a Java Web project. By the way, I recorded the process of setting up the strust project in idea.
Step 1: Open Idea and select create new project.
Step 2: configure the Tomcat server. Click new> Tomcat server on the right of application server to specify the Tomcat server path.
Step 3: Introduce the jar package on which strust depends. There are two methods:
First: Select Download and click Next. idea will automatically download the jar package required by strust2 from the Internet.
The second type: Select use library to use the local jar package, click Create, and select all the jar packages under the Struts-2.3.16.3 \ apps \ WEB-INF \ lib directory, click OK
Step 4: Click Next, enter the project name, specify the project path, and the project SDK (JDK path), and click Finish.
Step 5: Adjust tomcat configuration and click server and deployment in the upper right corner.
Step 6: To solve the problem that the strust library does not contain, select File-> project structure...
Step 7: write code Test
Create com. Test. action package and add testaction
package com.test.action;import com.opensymphony.xwork2.ActionSupport;public class TestAction extends ActionSupport{ @Override public String execute() throws Exception { return SUCCESS; }}
Modify strust. XML to add the following content:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"><struts> <package name="test" namespace="/" extends="struts-default"> <action name="testaction" class="com.test.action.TestAction"> <result name="success"> /index.jsp </result> </action> </package></struts>
Click Run in the upper-right corner. After the browser starts automatically, enter localhost: 8080/teststrust/testaction to test whether strust has been set up successfully!
Okay, it's a bit cool after writing it. It's a pure-handed script. Please indicate the source for reprinting.