简体   繁体   English

如何使本地JBOSS AS 7提供静态资源?

[英]How to make a local JBOSS AS 7 serve static resources?

As a standard, my static resources need to stay in a centralized location, out of my EARs / WARs (so that they can be updated without rolling out a new release for minor JS/CSS changes). 作为标准,我的静态资源需要保留在EAR / WAR之外的集中位置(以便可以对其进行更新,而无需针对较小的JS / CSS更改推出新版本)。

My HTML imports are relative, eg: 我的HTML导入是相对的,例如:

<script type="text/javascript" src="/resources/myApp/js/bootstrap.min.js"></script>

This means that the URLs to resources are different on every server (development, test, production..): 这意味着在每台服务器(开发,测试,生产..)上,资源的URL是不同的:

On dev-foobar.com : dev-foobar.com

dev-foobar.com /resources/myApp/js/bootstrap.min.js dev-foobar.com /resources/myApp/js/bootstrap.min.js

On tst-foobar.com : tst-foobar.com

tst-foobar.com /resources/myApp/js/bootstrap.min.js tst-foobar.com /resources/myApp/js/bootstrap.min.js

On foobar.com : foobar.com

foobar.com /resources/myApp/js/bootstrap.min.js foob​​ar.com /resources/myApp/js/bootstrap.min.js


But when I'm on my LOCAL Jboss ( localhost:8080 ), how can I instruct it to serve the same static resources to achieve the following URL ? 但是,当我使用LOCAL Jboss( localhost:8080 )时,如何指示它提供相同的静态资源来实现以下URL?

localhost:8080 /resources/myApp/js/bootstrap.min.js 本地主机:8080 /resources/myApp/js/bootstrap.min.js

JBoss handles all the static resources through a folder called welcome-content under $JBOSS_HOME : JBoss通过$JBOSS_HOME下名为welcome-content的文件夹处理所有静态资源:

C:\\Program Files\\EAP-6.2.0\\jboss-eap-6.2\\ welcome-content C:\\ Program Files \\ EAP-6.2.0 \\ jboss-eap-6.2 \\ welcome-content

Simply put something there, and it will be exposed in the root context. 只需在此处放置一些内容,它将在根上下文中公开。

For example, it's sufficient to copy the sample folders and file described in the question: 例如,复制问题中描述的示例文件夹和文件就足够了:

C:\\Program Files\\EAP-6.2.0\\jboss-eap-6.2\\ welcome-content\\resources \\myApp\\js\\bootstrap.min.js C:\\ Program Files \\ EAP-6.2.0 \\ jboss-eap-6.2 \\ welcome-content \\ resources \\ myApp \\ js \\ bootstrap.min.js

to end with the file (but not the folders) being accessible through the URL: 以可通过URL访问的文件(但不是文件夹)结尾:

localhost:8080/resources/myApp/js/bootstrap.min.js 本地主机:8080 / resources / myApp / js / bootstrap.min.js

Well done, Red Hat ! 干得好,红帽!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM