質問があります。些細なアプリケーションがあります。Spring MVCを使用したいのですが、JSPページでいくつかのフェイスレットを使用します(私がうまくいっていれば)。しかし、私はそれをすることができません。Geronimoを使用しています。Geronimoには、MyFacesJSFの実装があります。私は今、適切に書くにはどうすればいいfaces-config.xml
のか、何が欠けているのかはわかりません。ブラウザでページを開くと、Geronimoは次のようにスローしIllegalStateEcxeption
ます:このアプリケーション用に設定されたファクトリはありません。これは、faces-initializationがまったく機能しない場合に発生します。
アプリケーションでコントローラーを作成しました。
@Controller
public class BasicController {
@RequestMapping("/")
public ModelAndView index() {
ModelAndView mv = new ModelAndView();
mv.setViewName("main");
return mv;
}
@ModelAttribute("appVersion")
public String getVersion() {
return Version.VERSION + " (" + Version.BUILD_TIME + ")";
}
}
web.xmlでディスパッチャーサーブレットを宣言し、サーブレットに直面しています。
<servlet>
<servlet-name>sd</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sd</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<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>*.jsp</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
WEB-INF/sd-servlet.xmlでディスパッチャーサーブレットを構成しました。
<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/pages/" />
<property name="suffix" value=".jsp" />
</bean>
<context:component-scan base-package="eu.barbucha.trackAnniversaries.webLayer"/>
<mvc:annotation-driven/>
<mvc:resources location="/files/" mapping="/files/**"/>
私faces-config.xml
にはただ1つの宣言が含まれています:
<faces-config>
<application>
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
</application>
</faces-config>
そして最後に、JSPページを作成しました。
<?xml version='1.0' encoding='utf-8'?>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="files/basic.css" media="all"/>
</head>
<body>
<p>Example <h:outputText value="text"/>.</p>
<hr/>
<i>${appVersion}</i>
</body>
</html>