只有tomcat服務器纔會正確顯示.jsf頁面。當我嘗試通過eclipse添加項目並查看和測試它不會呈現.jsf代碼,而是將其顯示爲源代碼。我已經爲tomcat配置了eclipse,並且工作正常,但無法獲得.jsf頁面來呈現它,只是通過eclipse將其添加到服務器時顯示源代碼,但如果我導出.war文件並在tomcat/webapps上運行它,則它工作正常。從日食Eclipse不呈現jsf?
源代碼示例:
<?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">
<h:head>
<title>PCC Accounts Login</title>
</h:head>
<h:body>
<h:outputStylesheet name="style.css"></h:outputStylesheet>
<h:outputText>testing output text tag WITHOUT using value attributeHELLo ????</h:outputText>
<h:outputText value="testing outputText WITH using the value attribute" />
<h:form>
<h:inputText id="user_id" title="User Name" value="User Name" action="#{loginBean.setUsername}">User Name</h:inputText>
<h:inputText id="password" title="Password" value="Password" action="#{loginBean.setPassword}">Password</h:inputText>
<!-- <h:commandButton id="login" value="Login" action="accounts.jsf">Login Now</h:commandButton> -->
<h:commandButton id="login" value="Login" action="accounts.jsf" />
</h:form>
</h:body>
</html>
源代碼示例從日食出口和Tomcat的運行:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="j_idt2">
<title>PCC Accounts Login</title>
<link type="text/css" rel="stylesheet" href="/assign05_test/javax.faces.resource/style.css.jsf" />
</head>
<body>
<input type="hidden" name="j_idt9" value="j_idt9" />
<input id="j_idt9:user_id" type="text" name="j_idt9:user_id" value="User Name" title="User Name" />
<input id="j_idt9:password" type="text" name="j_idt9:password" value="Password" title="Password" />
<input id="j_idt9:login" type="submit" name="j_idt9:login" value="Login" />
</form>
</body>
</html>
SO,Eclipse是顯然不是渲染JSF頁面,但我加入了正確文件複製到Preferences/Java/BuildPath/UserLibraries。所以我不知道爲什麼它不起作用,但現在我正在通過導出.war然後在tomcat服務器上運行它,這是非常繁瑣的過程。任何人遇到這個問題?任何幫助將不勝感激,在此先感謝。
尊敬, 馬丁手
您還可以添加您的web.xml文件嗎? –
看看這是否有效。 http://stackoverflow.com/questions/2207616/jsf-tags-not-being-rendered-as-html –
@EvesMary Yeessss!那篇文章有幫助,它的工作,我的講師說在web.xml中添加url映射* .jsf,這就是我所做的,但我將它改爲了 Faces Servlet servlet-name> * .xhtml url-pattern> servlet-mapping>'及其固定值。我在那裏有' * .jsf url-pattern>',但被告知我需要調用jsf引擎。不要,謝謝! –
handmdmr