Idea build strust2 Development Environment

Source: Internet
Author: User

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.



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.