开发者

URL pattern of a web application running on TOMCAT 7

I am having a simple web application which has some static pages. The URL which comes in the browser address bar simply depends on file location in the project. http://computername:8080/mylogin/ is my home URL.

And below are the few URLs which come when I make a single cli开发者_如何转开发ck on the main home page.

http://computername:8080/mylogin/ssis/api.jsf
http://computername:8080/mylogin/ssis/dev.jsf

I am implementing a breadcrumb. And to generate it I am using javascript by Justin Whitford. Issue is this breadcrumb uses the browser URL to generate it. So my URL should be in some common fashion/pattern to have breadcrumb implemented properly.

I want to control these URLs. I want to make them like this. Home: http://myLogin/

sub pages:

http://mylogin/ssis/api/
http://mylogin/ssis/dev/

All this I want to have a proper implementation of breadcrumbs.


You can deploy your webapp to the context root by deleting Tomcat's default /webapps/ROOT folder altogether and renaming your webapp's mylogin.war file to ROOT.war.

This way you have http://computername:8080/

You can get rid of port 8080 by configuring Tomcat to listen on default HTTP port 80. Open Tomcat's /conf/server.xml, locate the <Connector port="8080"> element and edit the port in there.

Now you have http://computername/

You can change the computer name in platform properties or to add a forward in your hosts config file. On Windows, it's the system32/drivers/etc/hosts file. Just add the following line:

127.0.0.1 mylogin

Now you have http://mylogin/ (note that this works for local environment only!)

As to mapping the individual pages such as /foo.jsf on /foo, you could use a filter for this. It's a pretty tedious job. Instead of reinventing the wheel you may want to take a look at PrettyFaces.


It's only beyond me how exactly changing the hostname, port and context name is related to generating breadcrumbs. You might be exaggerating the concrete problem or using it the wrong way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜