JSF标签未呈现 [英] JSF tags are not being rendered

查看:110
本文介绍了JSF标签未呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始一个JSF项目(这是我第一次使用JSF),并且在呈现标签方面遇到了问题.我正在Eclipse中进行开发,并将TomCat用作服务器.

I'm starting a JSF project (this is the first time I've used JSF) and I'm having problems with the tags being rendered. I'm developing in Eclipse and using TomCat as a server.

我的web.xml文件: https://gist.github.com/code -curve/52902b7605b780dea93f

My web.xml file: https://gist.github.com/code-curve/52902b7605b780dea93f

Eclipse项目结构: http://snag.gy/P8Sts.jpg

Eclipse project structure: http://snag.gy/P8Sts.jpg

服务器启动日志: https://gist.github.com/code-curve /d1927a636052607ce16a

我正在使用以下URL访问文件:http://localhost:8080/DeutschAkademie/login.jsp和 据我了解,<h:form>标记应呈现为<form>,但相反,它呈现为<h:form>.有什么想法吗?

I am accessing the file with this url: http://localhost:8080/DeutschAkademie/login.jsp and as I understand the <h:form> tag should render as <form>, but instead it's instead rendering as <h:form>. Any ideas?

推荐答案

两个建议:

  1. 更新Faces Servlet的URL模式.默认配置可以用于*.jsp(无需使用*.faces或其他工具.不过,我还是建议使用*.xhtml.

  1. Update the URL pattern for Faces Servlet. The default configuration can be for *.jsp (no need to use *.faces or something else. Still, I would recommend using *.xhtml.

JSF 2可与Facelets一起使用,因此您不再需要使用旧的JSP.通过阅读您的login.jsp页面内容,您只需将扩展名从jsp重命名为xhtml即可使用.

JSF 2 works with Facelets, so you don't need to use old JSP anymore. By reading your login.jsp page content, you can just rename the extension from jsp to xhtml and it will work.

基于这些, web.xml 将如下所示:

Based on these, the web.xml will look like this:

<web-app>
    <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>*.xhtml</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>login.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

并具有login.xhtml文件.

要访问您的页面,您只需在浏览器地址栏中输入http://localhost:8080/DeutschAkademie/login.xhtml.

To access to your page you will only need to write http://localhost:8080/DeutschAkademie/login.xhtml in your browser address bar.

相关:

根据您的项目图片, WEB-INF/lib 文件夹是干净的.您应该将JSF 2库放在那里.添加它们,重新编译您的项目,然后重试.

Based on the picture of your project, the WEB-INF/lib folder is clean. You should drop the JSF 2 libraries there. Add them, recompile your project and try it again.

这篇关于JSF标签未呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆