[英]Load json file with absolute path
I have a java web app running on tomcat8 on my computer. 我在计算机上的tomcat8上运行了一个Java Web应用程序。 In a jsp I have a js function loading json files from WebContent folder, but I want to load this file "/home/test/test.json".
在一个jsp中,我有一个js函数从WebContent文件夹加载json文件,但是我想加载此文件“ /home/test/test.json”。
I searched but don't find how to do it. 我搜索了,但是找不到如何做。 How can I ?
我怎样才能 ?
Edit: I use this 编辑:我用这个
$('#table').bootstrapTable({
method : 'get',
url : '/testing/list.json',
cache : false,
height : 500,
striped : false,
pagination : false,
search : true,
showColumns : false,
columns : [ {
field : 'key',
title : 'Key',
align : 'left',
valign : 'midlle',
sortable : true
} ]
});
The easiest way to serve static content from another location is to register a new context with that docbase. 从另一个位置提供静态内容的最简单方法是在该文档库中注册新上下文。 Check the documentation but, for short, if you create the file
$CATALINA_BASE/conf/Catalina/localhost/testing.xml
with the content 检查文档,但总之,如果您使用内容创建文件
$CATALINA_BASE/conf/Catalina/localhost/testing.xml
<Context docBase="/home/test" />
then you will be able to request http://localhost:8080/testing/test.json . 那么您将可以请求http:// localhost:8080 / testing / test.json 。
The name of the xml file is used as the name of the context path. xml文件的名称用作上下文路径的名称。 Also, you don't need to have any WEB-INF or web.xml because Tomcat's defaults are usually enough.
另外,您不需要任何WEB-INF或web.xml,因为Tomcat的默认值通常就足够了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.