クラス JstlView
- 実装されているすべてのインターフェース:
- Aware、- BeanNameAware、- InitializingBean、- ApplicationContextAware、- ServletContextAware、- View
InternalResourceView の特殊化。Spring のロケールと MessageSource を使用して、JSTL のフォーマットとメッセージタグのロケールとリソースバンドルを指定する JSTL 固有のリクエスト属性を公開します。
InternalResourceViewResolver の一般的な使用箇所は、DispatcherServlet コンテキスト定義の観点から、次のようになります。
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="messages"/> </bean>ハンドラーから返されるすべてのビュー名は、明示的な JSTL サポートを有効にするためにこのビュークラスを使用して、JSP リソース (例: "myView" → "/WEB-INF/jsp/myView.jsp") に変換されます。
指定された MessageSource は、クラスパス内の "messages.properties" などのファイルからメッセージをロードします。これは、JSTL fmt タグ(メッセージなど)が使用する JSTL ローカライゼーションコンテキストとしてビューに自動的に公開されます。より洗練されたものにするために、標準の ResourceBundleMessageSource の代わりに Spring の ReloadableResourceBundleMessageSource を使用することを検討してください。もちろん、他の Spring コンポーネントは同じ MessageSource を共有できます。
 これは、主に InternalResourceView 自体の JSTL 依存関係を回避するための別個のクラスです。JSTL は、J2EE 1.4 まで標準 J2EE の一部ではなかったため、クラスパスで JSTL API jar が使用可能であると想定することはできません。
 ヒント: JSTL 式(c:out 値式など)内でアプリケーションコンテキスト内のすべての Spring Bean にアクセスできるようにするには、AbstractView.setExposeContextBeansAsAttributes(boolean) フラグを "true" に設定します。これにより、JSP 2.0 ページのプレーンな ${...} 式でそのようなすべての Bean にアクセスできるようになります。
- フィールドのサマリー- クラス org.springframework.web.servlet.view.AbstractView から継承されたフィールド- DEFAULT_CONTENT_TYPE- クラス org.springframework.context.support.ApplicationObjectSupport から継承されたフィールド- logger- インターフェース org.springframework.web.servlet.View から継承されたフィールド- PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
- コンストラクターの概要コンストラクター
- メソッドのサマリー修飾子と型メソッド説明- protected void- exposeHelpers- (HttpServletRequestEE request) Spring のロケールおよび MessageSource の JSTL LocalizationContext を公開します。- protected void- initServletContext- (ServletContextEE servletContext) JSTL の- jakarta.servlet.jsp.jstl.fmt.localizationContextコンテキストパラメーターを認識する JSTL 対応 MessageSource で MessageSource をラップします。- クラス org.springframework.web.servlet.view.InternalResourceView から継承されたメソッド- getRequestDispatcher, isContextRequired, prepareForRendering, renderMergedOutputModel, setAlwaysInclude, setPreventDispatchLoop, useInclude- クラス org.springframework.web.servlet.view.AbstractUrlBasedView から継承されたメソッド- afterPropertiesSet, checkResource, getUrl, isUrlRequired, setUrl, toString- クラス org.springframework.web.servlet.view.AbstractView から継承されたメソッド- addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, formatViewName, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponse- クラス org.springframework.web.context.support.WebApplicationObjectSupport から継承されたメソッド- getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, setServletContext- クラス org.springframework.context.support.ApplicationObjectSupport から継承されたメソッド- getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
- コンストラクターの詳細- JstlViewpublic JstlView()Bean として使用するコンストラクター。
- JstlView指定された URL で新しい JstlView を作成します。- パラメーター:
- url- 転送先の URL
 
- JstlView指定された URL で新しい JstlView を作成します。- パラメーター:
- url- 転送先の URL
- messageSource- JSTL タグに公開する MessageSource (JSTL の- jakarta.servlet.jsp.jstl.fmt.localizationContextコンテキストパラメーターを認識する JSTL 対応 MessageSource でラップされます)
- 関連事項:
 
 
- メソッドの詳細- initServletContextJSTL の- jakarta.servlet.jsp.jstl.fmt.localizationContextコンテキストパラメーターを認識する JSTL 対応 MessageSource で MessageSource をラップします。- オーバーライド:
-  クラス WebApplicationObjectSupportのinitServletContext
- パラメーター:
- servletContext- このアプリケーションオブジェクトが実行される ServletContext (非- null)
- 関連事項:
 
- exposeHelpersSpring のロケールおよび MessageSource の JSTL LocalizationContext を公開します。- オーバーライド:
-  クラス InternalResourceViewのexposeHelpers
- パラメーター:
- request- 現在の HTTP リクエスト
- 例外:
- ExceptionSE- 属性の追加中に致命的なエラーが発生した場合
- 関連事項: