jsf - 如何将每个文件夹中的 index.html 更改为/当我们在浏览器上访问它时

标签 jsf web

我有一些独特的问题,但我认为这不是问题,我只是想优化我网站的 url。

所以我想全部改掉

index.html

以每个文件夹为例

culture

文件夹,所以通常如果我们想要访问

index.html

在文化文件夹中我们可以输入

culture/index.html

对吧?但我只想输入

culture/

这有可能吗?如果是这样,我们如何生产?我正在使用 jsf 2 作为编程语言。

最佳答案

也许我误解了你的问题,但这可以通过 configuring welcome files 来完成在 web.xml 文件中:

Web Application developers can define an ordered list of partial URIs called welcome files in the Web application deployment descriptor. The purpose of this mechanism is to allow the deployer to specify an ordered list of partial URIs for the container to use for appending to URIs when there is a request for a URI that corresponds to a directory entry in the WAR not mapped to a Web component. This feature can make your site easier to use, because the user can type a URL without giving a specific filename.

Note: Welcome files can be JSPs, static pages, or servlets.

只是:

<welcome-file-list>
    <welcome-file>index.jsf</welcome-file>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

我已经在 WildFly 11 上测试过它并且它有效,我的项目结构是:

+ WebContent
   - index.xhtml
   + folder_a
        - index.xhtml
   + folder_b
        - index.html
   + folder_c
        - other_name.xhtml
        - some_name.html

当我输入时:

  • http://localhost:8080/myproject/ 我从 WebContent/index.xhtml
  • 获取内容
  • http://localhost:8080/myproject/folder_a 我从 WebContent/folder_a/index.xhtml
  • 获取内容
  • http://localhost:8080/myproject/folder_b 我从 WebContent/folder_b/index.html
  • 获取内容

Does the .xhtml file contain JSF content? is it parsed? I always thought defining a jsf/facelets file as a welcome file did not work and you needed http redirects via 'meta-inf'

.jsf' 是我在 web.xml` 文件中使用的扩展名:

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>

请阅读以下问题的答案以了解它是什么:

关于jsf - 如何将每个文件夹中的 index.html 更改为/当我们在浏览器上访问它时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45686881/

相关文章:

html - 指定列宽为h :panelGrid

web - `firstChild`和 `firstElementChild`有什么区别?

html - Bootstrap 中的中心输入字段

java - 如何在Eclipse中安装Web动态模块?

php - 访问 php 数组中的数据以创建新的结果数组

javascript - 如何在 JavaScript 中创建顶级命名空间

css - p :panelGrid inside p:panelGrid, 如何删除外部 p :panelGrid? 中的边框

html - 寻找 JSF/RichFaces 控件来弹出输入字段

validation - 无论如何强制 JSF 处理、验证和更新只读/禁用的输入组件

java - 将操作方法​​添加到动态创建的组合中