IDEA 搭建strust2開發環境

來源:互聯網
上載者:User

標籤:伺服器   idea   strust   java   

最近覺得IDEA這個java開發工具挺不錯的,於是嘗試從MyEclipse轉到IDEA來試試,用了才發現的確不錯,代碼提示和介面都用的挺爽的,於是便採用IDEA來開發java web項目,順便記錄一下IDEA搭建strust項目的過程。


step1:開啟IDEA選擇create New project選中


step2:配置tomcat伺服器,點擊Application server右側的New->tomcat server,指定tomcat伺服器的路徑



step3:引入strust所依賴的jar包,這裡有兩種方法

第一種:選擇Download直接Next,這時IDEA會自動從網上下載strust2所需的jar包


第二種:選擇Use library使用本地的jar包,點擊Create,並選擇struts-2.3.16.3\apps\WEB-INF\lib目錄下的所有jar包,點擊ok即可


step4:點擊next後,輸入項目名稱,指定項目路徑,以及project sdk(jdk路徑),點finish即可


step5:調整tomcat配置,點擊右上方,配置server和deployment如下




step6:解決strust庫未包含問題,選擇File->project Structure...




step7:寫代碼測試

建立com.test.action包添加TestAction

package com.test.action;import com.opensymphony.xwork2.ActionSupport;public class TestAction extends ActionSupport{    @Override    public String execute() throws Exception {        return  SUCCESS;    }}
修改strust.xml添加如下內容

<?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>

最後點擊右上方的運行就可以了,瀏覽器自動啟動後輸入localhost:8080/TestStrust/testaction才是測試strust是否搭建成功哦!



好了,寫完了,感覺有點羅嗦,純手打,轉載請註明出處



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.