廣告聯播

顯示具有 struts2 標籤的文章。 顯示所有文章
顯示具有 struts2 標籤的文章。 顯示所有文章

2014年11月24日 星期一

Struts 2 整合 Spring 配置實作

From: Polin Wei

Struts 2 要與 Spring 結合並不難,因為 Struts 2 本身就已經預留介面,在 struts2-core-2.x.x.jar 裡的 org.apache.struts2.default.properties 有這一段設定
### if specified, the default object factory can be overridden here
### Note: short-hand notation is supported in some cases, such as "spring"
###       Alternatively, you can provide a com.opensymphony.xwork2.ObjectFactory subclass name here
# struts.objectFactory = spring
 
 實作步驟如下:

Step 01: 建立一個帳號登入的 userLogin.jsp
Step 02: 建立對應的 userLogin Action Class: com.gu.test.spring.LoginAction
 
 Step 03: 利用Maven 來加入 Spring 的 Jar 檔. 可以參考 http://mvnrepository.com/artifact/org.apache.struts/struts2-spring-plugin
 
 Step 04: 配置 Struts & Spring : struts.xml
 
Step 05: 配置 Struts & Spring : applicationContext.xml
 
 Step 06: 配置 Struts & Spring : web.xml
 
登入 http://localhost:8080/guMIS/test/userLogin_input 測試,這樣就可以運作正常了。
 

2014年8月14日 星期四

如何在 eclipse 利用 maven 建立 struts2 並在 eclipse internal runtime Server: Tomcat 作開發環境測試

From: Polin Wei


主要目的:如何在 eclipse 利用 maven 建立 struts2 並在 eclipse internal runtime Server: Tomcat 作開發環境測試
平台:
eclipse:
Version: Kepler Service Release 2
Build id: 20140224-0627
maven:Maven Integration for Eclipse (Luna and newer) 1.5
tomcat:apache-tomcat-7.0.52_x64
java:jdk1.7.0_45_x64
jboss:JBoss EAP 6.2.0.GA

step01:建立一個 struts2-archetype-blank 的 maven 專案

可以按一下 Add Archetype,建立一個空的 Struts2 專案,相關欄位資訊可以查:http://struts.apache.org/release/2.2.x/docs/struts-2-blank-archetype.html
 

Step02:轉換成為 Dynamic Web project


選擇此專案 guEBS 按下滑鼠右鍵,選擇 Properties 裡的 Project Facets ,按下 Covert to faceted form...

先將 java 的版本改為 1.7 ,再將 Dynamic Web project 的 check box 打勾,此時下方會出現 "Further configuration available...",Content directory 原本是 WebContent ,修改為 src/main/webapp

再到 Deployment AssemblyMaven Dependencies 加入,然後按 Apply -> ok。
 

Step03:Deploy to Internal runtime Server:Tomcat 測試


執行 Maven build 時, 應該在 target 目前下會產生 guEBS-1.0.0-SNAPSHOT.war,這個檔直接可以佈署在 JBoss 下執行。

 
(繼續閱讀...)

WordPress 架站必備外掛