標籤:伺服器 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是否搭建成功哦!
好了,寫完了,感覺有點羅嗦,純手打,轉載請註明出處