我正在尝试修复 https://stackoverflow.com/questions/21162117/simplecrud-rejects-user-password来自 TomEE 邮件列表的人要求我使用 Maven 重现该错误。 所以我关注了Apache guide
新建目录,然后输入命令
mvn archetype:generate -DarchetypeGroupId=org.apache.openejb.maven -DarchetypeArtifactId=tomee-webapp-archetype -DarchetypeVersion=1.0.1
然后
cd tomee-demo
然后
mvn package tomee:run
然后我输入了war file 在
maven/tomee-demo/target/apache-tomee/webapps/
并尝试加载网页
http://localhost:8080/LAI_pezzi_Login/Login.xhtml
但是我收到了消息
The specified XML file does not have any associated style sheet. Document tree is shown below
<ui:composition template="/templates/layout.xhtml">
<ui:define name="content">
<h:form styleClass="loginPanelStyle">
<p:growl id="msgs" showDetail="true" sticky="false"/>
<p:panelGrid columns="2">
<f:facet name="header"> Login Panel </f:facet>
<h:outputText value="Username : "/>
<p:inputText id="username" value="#{loginController.username}" required="true" requiredMessage="Please Enter Username!" message="fc">
<f:validateLength minimum="1"/>
</p:inputText>
<h:outputText value="Password : "/>
<p:password id="password" value="#{loginController.password}" required="true" requiredMessage="Please Enter password!">
<f:validateLength minimum="1"/>
</p:password>
<f:facet name="footer">
<p:commandButton value="Submit" update="msgs" actionListener="#{loginController.login}" icon="ui-icon-check" style="margin:0"/>
</f:facet>
</p:panelGrid>
</h:form>
</ui:define>
</ui:composition>
我也试过在从Apache网站下载的Tomcat上部署WAR文件,WAR文件运行正常
最佳答案
如评论中所述,您需要通过在 web.xml
中指定一个 servlet 映射来告诉 JSF 它应该处理哪些 URL:
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
您对遗留配置文件的体验让我想起了为什么我只用 10' 杆接触 maven。
关于maven - 指定的 XML 文件没有任何关联的样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21402235/