JavaEE7の学習中です。まずはJSFとバッキングビーンの紐付けを確認しようとして、以下のファイルを作成しglassfishにデプロイしました。
h:commandButtonでactionを実行しても期待の結果(遷移)になりません。
exceptionが発生し、どうやらJSFがbeanを見つけられていないようです。
不足、または誤りがあるポイントについて、ご指導いただけないでしょうか。よろしくお願いします。
glassfish 4.1.1
java 1.8.0_45
// LoginBean.java import java.io.Serializable; import javax.enterprise.context.RequestScoped; import javax.inject.Named; @Named @RequestScoped public class LoginBean implements Serializable { private String name; public String change(String name){ return "/login/hogehoge?faces-redirect=true"; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
// login.xhtml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:knowledge="http://xmlns.jcp.org/jsf/composite/knowledgecomp"> <h:head> <meta charset="UTF-8" /> <title>emmMng v2 -login-</title> </h:head> <h:body> <h1>login.xhtml</h1> <div> <h:form id="form"> <h:inputText id="name" value="#{loginBean.name}"/> <h:commandButton action="#{loginBean.change()}" value="チェンジ"/> </h:form> </div> </h:body> </html>
// web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> <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>/faces/*</url-pattern> </servlet-mapping> </web-app>
// exception type Exception report messageInternal Server Error descriptionThe server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: /login.xhtml @17,67 value="#{loginBean.name}": Target Unreachable, identifier 'loginBean' resolved to null root cause javax.el.PropertyNotFoundException: /login.xhtml @17,67 value="#{loginBean.name}": Target Unreachable, identifier 'loginBean' resolved to null root cause javax.el.PropertyNotFoundException: Target Unreachable, identifier 'loginBean' resolved to null note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1.1 logs.

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/02/22 14:16
2016/02/22 14:29
2016/02/23 12:24
2016/02/23 15:30