Jsf h:form问题-通过h:commandbutton提交时返回404

Jsf h:form问题-通过h:commandbutton提交时返回404,jsf,Jsf,我正在开发一个JSF2.2应用程序。我看到一些使用h:form和h:commandbutton的奇怪行为 问题-我在say searchRecord.xhtml中有以下代码- <h:form> <!-- Input fields --> <h:commandbutton type="submit" value="Search" title="Search" action="#{bean.search}"/> </h:form>

我正在开发一个JSF2.2应用程序。我看到一些使用h:form和h:commandbutton的奇怪行为

问题-我在say searchRecord.xhtml中有以下代码-

<h:form>
    <!-- Input fields -->
    <h:commandbutton type="submit" value="Search" title="Search" action="#{bean.search}"/> 
</h:form>
我使用launchHandler servlet访问我的应用程序,该servlet验证请求参数并转发到searchRecord.xhtml

我可以看到searchRecord.xhtml。但现在当我点击时,我得到了404


作为标准,我们需要使用servlet,然后相应地转发。

我找到了解决问题的方法。这里的问题是错误的目录结构,我忽略了/WEB-INF下的资源不能通过URL访问这一点。感谢@BalusC指出这一点!!!。根据下面帖子的答案-

我重组了我的项目如下-

My Application
|- Java Resource
|----src -> contains java files
|- WebContent
|---- META-INF
|---- Resources -> contains img, css and JS files in respective folders
|---- JSF
|      |--Contains client .xhtml files
|---- WEB-INF
|      |--template -> contains the master templates for my application
|      |--web.xml
|---- index.xhtml
现在导航按预期进行,所有页面都显示出来


我还计划使用JSF2.2配置参数,并将资源放在WEB-INF下。

您的bean.search方法中写了什么?faces-config.xml中定义的导航规则正确吗?type=submit是多余的。。。如果我没记错的话,它有时甚至可能会引起问题,哪种行为看起来是正确的不,不是。尝试在浏览器的地址栏中输入该URL。尝试以这种方式访问任何/WEB-INF文件。包括web.xml。你会发现这是不可能的。不是没有原因的。@EAP-bean.search方法正在根据用户输入返回结果字符串。如果用户参数有效且在数据库中找到一行,则高级实现将返回success,如果用户参数无效,则返回error。根据结果,将导航到下一页。@BalusC-是的,这是正确的。我无法访问/WEB-INF中的任何资源。您能指出我做错了什么吗?注意-由于工作场所的限制,我不能在这里发布全部代码。抱歉!
My Application
|- Java Resource
|----src -> contains java files
|- WebContent
|---- META-INF
|---- Resources -> contains img, css and JS files in respective folders
|---- JSF
|      |--Contains client .xhtml files
|---- WEB-INF
|      |--template -> contains the master templates for my application
|      |--web.xml
|---- index.xhtml