2009-08-28 6 views
0

私は、Struts2をMVCとして、Hibernateをデータアクセス用に、そしてビジネスロジックで春に使用するアプリケーションを作成する必要がありました。 また、テンプレート作成のためにpresentaionとsitemeshにVelocityを使用する必要がありました。Velocity + Struts2 + Sitemesh + Spring + Hibernate統合web.xmlの設定方法は?

HibernateとSpringの統合は簡単ですが、Spring、Sitemesh、およびVelocityをStrutsと統合するのはわかりませんが、Velocity、Spring、およびSitemshをStruts2と個別に使用できます。この例に示すように、もちろん

http://www.rkcole.com/articles/struts/crudTutorial/step4.html sitemeshと春が

<listener> 
<listener-class> 
org.springframework.web.context.ContextLoaderListener 
</listener-class> 
</listener> 

<filter> 
<filter-name>sitemesh</filter-name> 
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class> 
</filter> 


<filter-mapping> 
<filter-name>sitemesh</filter-name> 
<url-pattern>/*</url-pattern> 
<dispatcher>FORWARD</dispatcher> 
</filter-mapping> 

としてStruts2のweb.xmlの構成と統合することができます今私の仕事は、この組み合わせで速度を統合することである....... ........

通常、私は、次の

<servlet-class> 
org.apache.velocity.tools.view.servlet.VelocityViewServlet 
</servlet-class> 
<load-on-startup>10</load-on-startup> 
</servlet> 
<servlet-mapping> 
<servlet-name>velocity</servlet-name> 
<url-pattern>*.vm</url-pattern> 
</servlet-mapping> 

を使用する速度とStruts2のを統合する............ ..................................................私の質問はどのように設定している

............................... `

<servlet-mapping> 

`、それだけの速度、またはsimemeshまたは別に設定する必要があります

完全なweb.xmlとその他の手順に従ってください返すことができます場合は続行する方法を教えてください。これにより

よろしく

T.Thamilvaanan

答えて

3

雅は、最終的に私は読書をたくさんした後、このweb.xmlファイルを持って、検索............

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 


<!-- A part in Spring Integration--> 
<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value> 
</context-param> 



<!-- All the filters starts here--> 

<filter> 
    <filter-name>struts-cleanup</filter-name> 
    <filter-class>org.apache.struts2.dispatcher.StrutsPrepareFilter</filter-class> 
</filter> 


<!-- This is used to integrate sitemesh with Struts2--> 

<!-- 
I am using Velocity to create sitemesh decorators so I have to use 

    VelocityPageFilter to integrate 

    Sitemesh (i.e. Sitemesh in velocity) + Struts2  
In the web.xml, the VelocityPageFilter should be placed between the 
    ActionContextCleanUp (StrutsPrepareFilter since 2.1.3 ) and 
and the FilterDispatcher (StrutsExecuteFilter since 2.1.3) 
--> 

<filter> 
    <filter-name>sitemesh</filter-name> 
    <filter-class>org.apache.struts2.sitemesh.VelocityPageFilter</filter-class> 
</filter> 

<filter>  
<filter-name>struts2</filter-name> 
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class> 
</filter> 

<filter-mapping> 
<filter-name>struts-cleanup</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

<filter-mapping> 
<filter-name>sitemesh</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

<filter-mapping> 
    <filter-name>struts</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 



<!-- Spring Integration--> 
<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 



    <!--Finally since I am velocity pages in struts2 MVC I am using 
VelocityViewServlet  to Integrate struts2 with Velocity --> 

    <servlet> 
    <servlet-name>velocity</servlet-name> 
    <servlet-class>org.apache.velocity.tools.view.VelocityViewServlet 
    </servlet-class> 
    <init-param> 
    <param-name>org.apache.velocity.toolbox</param-name> 
    <param-value>/WEB-INF/tools.xml</param-value> 
    </init-param> 
    <init-param> 
    <param-name>org.apache.velocity.properties</param-name> 
    <param-value>/WEB-INF/velocity.properties</param-value> 
    </init-param> 
    </servlet> 


<!-- Map *.vm files to Velocity --> 
<servlet-mapping> 
    <servlet-name>velocity</servlet-name> 
    <url-pattern>*.vm</url-pattern> 
</servlet-mapping> 



    <session-config> 
     <session-timeout> 
      30 
     </session-timeout> 
    </session-config> 


    <welcome-file-list> 
     <welcome-file>index.vm</welcome-file> 
    </welcome-file-list> 


    </web-app> 

希望、これは結構です、テストし、あなたが知っています。

乾杯............

よろしく

Thamilvaanan