私の意見では、Spring
そしてJSF
- 両方とも問題なく使用できます。もちろん、それは主に、これらのフレームワークを使用するための要件と好みに依存します。
Spring -トランザクション管理、依存性注入、セキュリティ、およびその他の多くの機能の非常に優れた方法がありますが、プレーンJSF
はこの種の機能をそのままでは提供しませんが、JSF にはビューをレンダリングする非常に優れた方法があります。そのため、両方のフレームワークのこれらの機能を混ぜ合わせると、結果的にシンプルになる可能性があります。JSFには、次のようなさまざまなフレームワークが構築されています。
私の意見では、 を使用していれば、ビューの開発を簡素化できますJSF
。JSF にはManagedBeanがあり、構成に応じて、Spring コントローラーのようにリクエストを処理します。
実際の構成は非常に簡単です。次のものが必要です。
faces-config.xml
SpringBeanFacesELResolverを含むファイル:
<?xml version='1.0' encoding='UTF-8'?>
<faces-config 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-facesconfig_2_0.xsd"
version="2.0">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
<navigation-rule>
<!-- your rules here -->
</navigation-rule>
</faces-config>
春のapplicationCotext.xml
ファイル。通常の春の設定、JSF
具体的なものは何もありません。
これweb.xml
は次のようになります。
<web-app 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_3_0.xsd"
version="3.0">
<!-- other config -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- other of config -->
</web-app>
で最も優れているのJSF
はView ScopeJSF
です。これは、 を使用していた場合、デフォルトで失われますが、これSpring
を失いたくないことは間違いありません。ここでは、View Scopeを統合して機能させる方法について説明します。JSF
Spring
アプリケーションをゼロから作成する場合は、これら 2 つのフレームワークを選択して統合しますが、これは私の意見です。これでいくつかの問題が解決することを願っています。