从网址中删除应用程序名称 [英] remove application name from URL

查看:117
本文介绍了从网址中删除应用程序名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站使用JSF,URL似乎是 http://mysitename.com/wompower6 /faces/home.xhtml

my site uses JSF and the url appears to be, http://mysitename.com/wompower6/faces/home.xhtml

我正在使用prettyfaces,因此,如果我在pretty-config.xml中使用以下内容,则可以将名称更改为 http://mysitename.com/ wompower6 /home

I am using prettyfaces, so if I use the following in pretty-config.xml, i can change the name to http://mysitename.com/wompower6/home

<url-mapping id="home">
    <pattern value="/home" />
    <view-id value="/faces/home.xhtml" />
</url-mapping>

我的问题是

  1. 我如何删除该应用程序 名称wompower6,以便URL 成为mysitename.com/home吗?

  1. how can i remove the application name wompower6 , so that the url becomes mysitename.com/home ?

<welcome-file>home.xhtml</welcome-file>, 但这似乎不起作用.什么时候 我输入mysitename.com,但没有 映射到home.xhtml.任何线索 在这里?

in my web.xml, i have <welcome-file>home.xhtml</welcome-file>, but this does not seem to work. When i type, mysitename.com, it does not get mapped to home.xhtml. any clue here?

推荐答案

如何删除应用程序名称wompower6,以使URL变为mysitename.com/home?

这是一个Webapp <Context>设置,其配置取决于所使用的servlet容器.例如,如果您使用的是Tomcat,则基本上有2个选项可以使您的Web应用程序成为根Web应用程序.

This is a webapp <Context> setting and configuration is dependent on the servletcontainer used. If you're for example using Tomcat, then there are basically 2 options to make your webapp the root webapp.

  1. 将WAR文件重命名为ROOT.war,Tomcat默认将其部署在上下文根目录上.

  1. Rename the WAR file to ROOT.war and Tomcat will by default deploy it on context root.

Webapp/META-INF/context.xml(或Tomcat/conf/server.xml,取决于您要在何处定义)中<Context>元素的path属性设置为空字符串.例如

Set path attribute of <Context> element in Webapp/META-INF/context.xml (or Tomcat/conf/server.xml, depending where you'd like to define it) to an empty String. E.g.

<Context path="" ...>

其他容器也支持类似的构造.有关详细信息,请查阅其文档.如果使用的是类似Eclipse的IDE,则还可以在项目属性的 Web项目设置属性中进行设置(右键单击项目并选择 Properties ).将上下文根值设置为/.

Other containers support similar constructs. Consult their documentation for detail. If you're using an IDE like Eclipse, then you can also set it in the Web Project Settings property of the project properties (rightclick project and choose Properties). Set the Context root value to just /.

在我的web.xml中,我有home.xhtml,但这似乎不起作用.当我键入mysitename.com时,它不会映射到home.xhtml.这里有任何线索吗?

我假设您是在谈论<welcome-file>设置.这必须指向物理上存在的文件,而不是虚拟URL,例如/faces/*.基本上有两种方法可以解决此问题:

I assume that you're talking about the <welcome-file> setting. This has to point to a physically existing file, not to a virtual URL, such as /faces/*. There are basically two ways to overcome this:

  1. 提供一个物理上存在的 /faces/home.xhtml文件(甚至可以将其保留为空).

  1. Provide a physically existing /faces/home.xhtml file (it can even be left empty).

*.xhtml替换web.xmlweb.xmlFacesServlet映射的难看的/faces/* URL模式,以便它会在每次请求XHTML文件时启动.

Replace the ugly /faces/* URL pattern of the FacesServlet mapping in web.xml by *.xhtml so that it will just kick in on every request for a XHTML file.

<url-pattern>*.xhtml</url-pattern>

这样,您无需摆弄/faces/* URL模式.

This way you don't need to fiddle with /faces/* URL patterns.

这篇关于从网址中删除应用程序名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆