2

ですから、私はJSFを初めて使用します。数日前に使い始めたばかりで、YouTubeのチュートリアルと数冊の本から学ぼうとしています。しかし、なぜこれが機能しないのかわかりません。これが私のコードです:

    <h:form styleClass="formStyle">
        <h1>Log In</h1>
        <fieldset id="inputs">
            <h:inputText id="username" type="text"  value="#{redirectBean.name}">
            </h:inputText>
            <h:inputSecret id="password" type="password"  value="#{redirectBean.password}">
            </h:inputSecret>
        </fieldset>
        <fieldset id="actions">
            <h:button type="submit" styleClass="test" value="Log in" outcome="#{redirectBean.login}">
            </h:button>
        </fieldset>
    </h:form>

redirectBean.javaは、3つのプライベート文字列(login = "welcome"、名前、およびパスワード)とそれらのゲッター/セッターを含む単純なクラスです。

ログインボタンをクリックすると、welcome.xhtmlにリダイレクトされますが、redirectBean.nameまたはredirectBean.passwordに変更は加えられていません。

何かご意見は?私は何が欠けていますか?

編集:BalusCは、代わりにh:commandButtonを使用する必要があると説明しましたが、リダイレクトされませんでした。何度か何度も理由を理解しようとした後、これは現在取得しているサーバーログです(コマンドボタンでリダイレクトされていますが、まだBeanに値が渡されていません。RIとMyFacesについても何かがわかりました。競合していますが、クラスパスをいじくり回すと修正されたようです):

SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener     at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5332)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:498)   at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
    at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
    at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
    at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
    at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at
com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
    at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)     at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662) Caused by:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener     at
org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2743)
    at
org.apache.catalina.core.StandardContext.addApplicationListener(StandardContext.java:1966)
    at
com.sun.enterprise.web.TomcatDeploymentConfig.configureApplicationListener(TomcatDeploymentConfig.java:235)
    at
com.sun.enterprise.web.TomcatDeploymentConfig.configureWebModule(TomcatDeploymentConfig.java:94)
    at
com.sun.enterprise.web.WebModuleContextConfig.start(WebModuleContextConfig.java:274)
    at
com.sun.enterprise.web.WebModuleContextConfig.lifecycleEvent(WebModuleContextConfig.java:172)
    at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:149)
    at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5329)
    ... 39 more Caused by: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener     at
org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
    at
org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
    at
org.apache.catalina.core.StandardContext.loadListener(StandardContext.java:4806)
    at com.sun.enterprise.web.WebModule.loadListener(WebModule.java:1599)
    at
org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2740)
    ... 46 more

WARNING: java.lang.IllegalStateException: ContainerBase.addChild:
start: org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener     at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:921)
    at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
    at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
    at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
    at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
    at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at
com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
    at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)     at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)

SEVERE: Exception while invoking class
com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener     at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:138)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
    at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
    at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
    at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at
com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
    at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)     at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)

SEVERE: Exception while loading the app SEVERE: Exception while
loading the app : java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
org.apache.myfaces.webapp.StartupServletContextListener
4

1 に答える 1

2

<h:commandButton>ではなく、を使用する必要があります<h:button><h:button>GETリクエストを送信するだけで、POST<h:commandButton>でフォームを送信します。

<h:commandButton styleClass="test" value="Log in" action="#{redirectBean.login}" />

public String login() {
    // Do your business job.

    return "welcome";
}

参照:

于 2012-06-23T14:18:23.350 に答える