版权声明:欢迎评论和转载,转载请注明来源。 https://blog.csdn.net/zy332719794/article/details/51787799
主要思路是使用自定义模版来实现。
1、定位到路径:
GEOSERVER_DATA_DIR/workspaces/{workspace}/{datastore}/{featuretype}/
2、在上一步的目录下创建三个空的文本文件,并将文件名称修改为: header.ftl、content.ftl、footer.ftl
3、用记事本打开content.ftl文件,将下面的文本内容粘贴复制进去,然后保存。
[ <#list features as feature> { "Type": "${type.name}" <#list feature.attributes as attribute> <#if !attribute.isGeometry> , "${attribute.name}": "${attribute.value}" </#if> </#list> } </#list> ,{} ]
AI 代码解读
4、在客户端调用WMS getFeatureInfo请求就可以看到返回的是JSON字符串了。
注意:这种方式返回的数据如果有“数值”类型的数据将一并当作字符串处理。