只有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