0

我在使用 JSF 的简单 HelloWorld 项目时遇到问题

我猜问题出在我的 web.xml 文件(如下)中,除了welcome-file-list 标记和子项之外,所有内容都是自动生成的。

我的主要问题是:
1)我如何知道哪个 url 将启动用户浏览网络应用程序的过程?
2)运行应用程序时如何更改默认网址(我注意到更改 web.xml 中的显示名称标签并没有阻止它显示为 /Hello/)?
3)我需要像我一样在welcome-file-list中的web.xml中注册jsps吗?
4)我需要在其他地方注册吗?

#######Behavior########

当我右键单击项目(名为 Hello) -> 运行方式 -> 在服务器上运行 -> 选择 JBoss7 时,我被定向到页面 localhost:8080/Hello/ 并收到 404 错误

我希望能够导航到页面 localhost:8080/faces/HelloWorld.jsp 来查看文件,但是这样做会导致 404 错误

我可以通过导航到 localhost:8080/Hello/HelloWorld.jsp 得到 500 错误

$JBossHome/standalone/deployments 中有 Hello.war 和 Hello.war.deployed 而不是 Hello.war.failed

#####Notes######

*我在项目中没有其他 jsp,也没有导航规则(我假设我不需要/想要它们只有一个 jsp)
*我正在使用 JBoss7 和 Eclipse,除了 JSF 之外,我没有对“项目”进行任何添加facets"
*该项目是一个“动态网络项目”
*我使用的是 JSF 2.1.6 Mojarra

我确定我需要发布其他信息/日志文件/等。让我知道

#################################
##########HelloWorld.jsp#########
###note this is within body tag##
###all autogenerated stuff I ####
#####didn't bother to post#######

<f:view>
    <h:form>
        Hello, World!
    </h:form>
</f:view>




#################################
#############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_3_0.xsd" version="3.0">
  <display-name>Hello</display-name>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
  <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>/faces/*</url-pattern>
  </servlet-mapping> 
    <welcome-file-list>
        <welcome-file>/HelloWorld.jsp</welcome-file>
    </welcome-file-list>
</web-app>
4

0 回答 0