我正在 eclipse 中使用 JSF 2.2 和 Servlet 3.1 (Java EE7) 做一个项目。我遇到的第一个问题是 pom.xml 中的错误:
<packaging>war</packaging>
错误:web.xml 丢失且设置为 true。
我在互联网上进行了研究,并在我的 pom.xml 中添加了以下几行
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
之后错误就消失了,但是运行项目时出现错误:
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
我又在网上搜索了一下,在pom.xml中放入了以下几行
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
问题解决了,只有当访问时,例如:
http://localhost:8080/MeuSistema/Login.jsf http://localhost:8080/MeuSistema/Login.jsf
(我把映射为jsf来投资xhtml)
他通过 jsp 更改了 jsf,声明如下:
HTTP 状态 404 - /MeuSistema/Login.jsp
出于好奇,将 .jsf 更改为 .xhtml 以查看是否至少打开
文件,它返回以下内容:
HTTP 状态 404 - 在外部上下文中未找到 /Login.xhtml 作为资源
我还找到了强制读取 web.xml 的替代方法
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webxml>src/main/webapp/WEB-INF/web.xml</webxml>
<warSourceDirectory>src/main/webapp/</warSourceDirectory>
</configuration>
</plugin>
但问题依然存在。
按照我的 pom.xml 和 web.xml:
http://pastebin.com/43nqctAn http://pastebin.com/43nqctAn
http://pastebin.com/GbqR9j9v http://pastebin.com/GbqR9j9v
嗯,看来是没有读取web.xml。有趣的是在
不是任何控制台错误。
有什么问题吗?
感谢您的关注。