当我使用Eclipse中的Tomcat 8.0启动Java EE项目时,我无法设置在浏览器中加载的默认页面.我正在尝试学习JSF,所以我遵循了本教程
一切正常,但是当我右键单击login.xhtml或welcome.xhtml文件并选择"在服务器上运行/运行" 时,我只能看到创建的页面.
到目前为止,我创建的所有其他Web应用程序在我启动整个项目时都加载了默认页面.默认行为是加载index.html页面(如果有的话,可能是index.jsp).所以我添加index.html和index.xhtml页面到我的WEB-INF项目文件夹,希望其中至少有一个将被显示.然而,没有任何反应.浏览器始终只显示localhost:8080/JSFFaceletsTutorial/URL 上的页面,但页面是白色的,甚至不是错误消息.我想我一直在解决这个问题的过程中遇到错误404,但是,我不再能够重现这个错误,我不记得是什么导致了它.
我发现可以更改默认的起始页面
但是,它对我也不起作用.无论我是否编辑web.xml文件,我都得到相同的结果.
更令人费解的是,当我尝试更改网络浏览器时:"窗口/网络浏览器/ ..."它在外部网络浏览器中的作用时间与内部Eclipse网络浏览器不同.内部总是空白页面 - 但外部网络浏览器曾经设法显示index.html页面 - 但它是一些过时的版本.尽管我完全确定我编辑了它,保存了更改,重新启动了服务器......但它仍然显示了页面的过时版本.即使在这种情况下,它仍然忽略了web.xml文件中所做的更改.但是当我现在尝试它时,它再次在所有浏览器中显示空白页面.除了编辑web.xml文件外,我不知道我做了什么改变......
我的猜测是问题在于我还没有完全掌握的JSF技术.这是因为当我选择使用右键单击"运行方式/在服务器上运行" 来运行login.xhtml和welcome.xhtml页面时,这些页面的URL将显示localhost:8080:路径/JSFFaceletsTutorial/faces/login.xhtml和/JSFFaceletsTutorial/faces/welcome.xhtml.这很奇怪,因为我的项目中没有任何目录"faces".键入所有可能的排列:
<welcome-file-list>
<welcome-file>faces/index.html</welcome-file>
<welcome-file>faces/index.xhtm</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
在这web.xml也没有帮助.当我在那里输入完整地址时,它没有帮助.
以下是我在控制台中收到的警告(我跳过了INFO日志条目):
"2014年12月19日上午9:39:55 org.apache.tomcat.util.digester.SetPropertiesRule开始警告:[SetPropertiesRule] {Server/Service/Engine/Host/Context}将属性'source'设置为'org.eclipse. jst.jee.server:JSFFaceletsTutorial'找不到匹配的属性....警告:JSF1074:已经注册了名为'loginBean'的托管bean.用com.tutorial.LoginBean替换现有的托管bean类com.tutorial.LoginBean .2014年12月19日上午9:39:57 org.apache.coyote.AbstractProtocol start"
我不确定这是否有用.我现在没有想法了.
我尝试过xmlns:h="jakarta.faces.html"、xmlns:h="http://jakarta.faces.html"、xmlns:h="https://jakarta.faces.html"和其他类似的字符串,但似乎没有任何效果。
我已将我的应用程序从JSF 1.2迁移到2.2.
它在java.sun.com域 上使用XML命名空间xmlns:f="http://java.sun.com/jsf/core".但是,Oracle的Java EE 7教程正在使用xmlns.jcp.org域名
上的XML命名空间xmlns:f="http://xmlns.jcp.org/jsf/core".
推荐哪一个,为什么会改变?
我的服务器是glassfish v3,我的浏览器是firefox 3.6.3,我正在使用Netbeans 6.8我的问题是为什么textfield没有显示在我的浏览器中.我只看到标签.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Lookup</title>
</h:head>
<h:body>
<fieldset>
<legend>Enter Your Customer ID</legend>
<p>Legal ids are id001, id002, and id003.</p>
<f:view>
<h:form>
Customer ID:
<h:inputText value="#{bankForm.customerId}" />
<h:commandButton value="Show Current Balance"
action="#{bankForm.findBalance}" />
</h:form>
</f:view>
</fieldset>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<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>*.jsf</url-pattern>
</servlet-mapping>
<session-config> …Run Code Online (Sandbox Code Playgroud) 我是JSF的新手,但我的JSF标签没有在xhtml文件中呈现,我尝试了所有可能的解决方案,但问题没有解决
我的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>JSFProject</display-name>
<welcome-file-list>
<welcome-file>JSFProject/index.html</welcome-file>
<welcome-file>JSFProject/index.htm</welcome-file>
<welcome-file>JSFProject/index.jsp</welcome-file>
<welcome-file>JSFProject/default.html</welcome-file>
<welcome-file>JSFProject/default.htm</welcome-file>
<welcome-file>JSFProject/default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<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>
</web-app>
Run Code Online (Sandbox Code Playgroud)
我的example.xhtml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Example</title>
</head>
<body>
<h:form>
Some random data: <h:inputText/><br/> <!-- Textfield ignored -->
Some other data: <h:inputText/><br/> <!-- Textfield ignored …Run Code Online (Sandbox Code Playgroud) 今天我正在申请一个学校项目.我们的Bootsfaces没有任何问题,但突然间我似乎无法显示组件(见图).我不知道是什么导致了这种意想不到的行为,因为它之前有效.没有任何内容更改为.xhtml页面.Chrome控制台和Payara控制台中的错误日志均提供0错误.
我正在使用Payara 5.181和Java EE 7.
编辑:
删除Payara服务器中的"生成"文件夹并重新启动PC似乎可以解决此问题,但过了一段时间(无法准确再现原因)页面再次变为空白.
.xhtml文件
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:b="http://bootsfaces.net/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Kies je cartracker</title>
<h:outputStylesheet name="default.css" library="css" />
</h:head>
<h:body>
<h1>Kies je cartracker:</h1>
<b:dataTable value="#{tourmanager.allCartrackers}"
var="tracker">
<b:dataTableColumn>
<f:facet name="header">
<h:outputText value="Vehicle" />
</f:facet>
<h:outputText value="#{tracker.vehicle.serieNr}" />
</b:dataTableColumn>
<b:dataTableColumn>
<f:facet name="header">
<h:outputText value="Kies cartracker" />
</f:facet>
<h:form>
<b:commandButton action="#{tourmanager.pickCartracker(tracker)}"
value="Pick car" >
</b:commandButton>
</h:form>
</b:dataTableColumn>
</b:dataTable>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
的pom.xml
<dependency>
<groupId>net.bootsfaces</groupId>
<artifactId>bootsfaces</artifactId>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
web.xml中
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet> …Run Code Online (Sandbox Code Playgroud) 我正在测试coreservlets网站上的应用程序"jsf-blank",以便了解jsf如何工作,但我的浏览器没有显示xhtml页面的内容.
我使用Tomcat 6和Eclipse Indigo.
你知道为什么我的浏览器中的页面是空白的吗?
谢谢您的帮助.
谢谢,但它不适用于jsp指令,这是我的web.xml的内容:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
最后更新 :
我尝试了你的解决方案,但我有同样的问题,jsf标签不是由浏览器呈现(我是JSF的新手).
我的测试非常简单:
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
index.xhtml:
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title><h:outputText value="First JSF Application" /></title>
</h:head>
<h:body>
<h:outputText value="Test" …Run Code Online (Sandbox Code Playgroud) 我有这个:
<html
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
>
<h:selectOneRadio>
<f:selectItem value="1" itemValue="1" itemLabel="123"/>
<f:selectItem value="2" itemValue="2" itemLabel="321"/>
</h:selectOneRadio>
Run Code Online (Sandbox Code Playgroud)
我得到了这个:
<f:selectItem value="1" itemValue="1" itemLabel="123"></f:selectItem>
<f:selectItem value="2" itemValue="2" itemLabel="321"></f:selectItem>
<select name="j_idt5" size="1"></select>
Run Code Online (Sandbox Code Playgroud)
为什么xmlns:f="http://xmlns.jcp.org/jsf/core"标签没有呈现?
我在Netbeans 7.3上使用JBoss AS 7.
我正在启动一个JSF项目(这是我第一次使用JSF)并且我在渲染标记方面遇到了问题.我正在Eclipse中开发并使用TomCat作为服务器.
我的login.jsp文件:https://gist.github.com/code-curve/e7e557262d407dddd1f3
我的web.xml文件:https://gist.github.com/code-curve/52902b7605b780dea93f
Eclipse项目结构:http://snag.gy/P8Sts.jpg
服务器启动日志:https://gist.github.com/code-curve/d1927a636052607ce16a
我正在使用此url访问该文件:http://localhost:8080/DeutschAkademie/login.jsp并且据我所知,<h:form>标记应该呈现为<form>,但相反它呈现为<h:form>.有任何想法吗?
我有一个空白页,当我尝试打开我的网页的http://本地主机:8084/GPSI-工作/ admin.xhtml但是当我尝试这样的http://本地主机:8084/GPSI-工作/面/ admin.xhtml那工作在哪里是问题,我在我的项目中使用模板.
jsf ×9
facelets ×3
java ×3
jsf-2 ×3
bootsfaces ×1
eclipse ×1
homescreen ×1
jakarta-ee ×1
java-ee-7 ×1
jsf-2.2 ×1
primefaces ×1
templates ×1
tomcat ×1
welcome-file ×1