說明:
在用Geoserver發布Postgis發布的圖層后,去LayerPreview中預覽,但是選openlayers時,沒有跳轉到預覽頁面,而是彈出了下載WMS。
解決方案:
用KML方式預覽時,出現報錯提示:XML 解析錯誤:格式不佳。 順着這個提示去找了好久,並沒有找到Geoserver的實質性解決問題的方法。
用記事本打開下載的WMS文件,內容如下,發現內容格式和樣式中的GML格式有點像
抱着試一試的態度,看了一下圖層發布時應用的樣式,果然看到默認樣式下方的圖裂開了,被改了,所以發布的圖層找不到此樣式。
把他改成默認的line樣式,再去layerPreview中預覽就正常了
##此圖為修改正確后的,原來錯誤的樣式這里是裂開的圖片(錯誤的沒截圖)
下載來的WMS里包含錯誤信息,還是要重視,根據錯誤信息去查問題會精准一些
最后附上默認line樣式:
<?xml version="1.0" encoding="UTF-8"?> <StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- a Named Layer is the basic building block of an SLD document --> <NamedLayer> <Name>default_line</Name> <UserStyle> <!-- Styles can have names, titles and abstracts --> <Title>Default Line</Title> <Abstract>A sample style that draws a line</Abstract> <!-- FeatureTypeStyles describe how to render different features --> <!-- A FeatureTypeStyle for rendering lines --> <FeatureTypeStyle> <Rule> <Name>rule1</Name> <Title>Blue Line</Title> <Abstract>A solid blue line with a 1 pixel width</Abstract> <LineSymbolizer> <Stroke> <CssParameter name="stroke">#0000FF</CssParameter> </Stroke> </LineSymbolizer> </Rule> </FeatureTypeStyle> </UserStyle> </NamedLayer> </StyledLayerDescriptor>