I am learning to use GeoServer. I published a layer from a shp, which I created by importing a csv file into QGIS in utf-8 encoding, and exporting as shp in utf-8 encoding. I added a style to the layer. I got the style from geoserver cookbook for point with default label. The only thing I changed is the contents in <ogc:PropertyName>, as I have to set it to the name of the column I want to show. I changed it into school_name. But then the layer doesn't show in layer preview.

Things I've tried:

  1. change <ogc:PropertyName> content to the column lat. This column contains latitude. The type shown on GeoServer is double. This works.
  2. change <ogc:PropertyName> content to school. This column contains Chinese characters. The type shown on GeoServer is string. The layer shows but the labels are ??.
  3. change <ogc:PropertyName> content to school and change the xml encoding to utf-8 and UTF-8. Again, the layer shows, but the labels are ??
  4. change <ogc:PropertyName> content to school and add format_options=CHARSET:UTF-8 in the WMS request. Again, the layer shows, but the labels are ??.
  5. change content to postal_code. This column contains postcodes which are just numbers. The type shown on GeoServer is long. The layer doesn't show.

So how do I show Chinese labels? And how do I fix the problem where column names with underscore doesn't show?

  • make sure you correctly set the character encoding when you imported the shapefile
    – Ian Turton
    Commented Mar 22, 2020 at 10:23
  • I set the encoding of the data store (type Directory of spatial files) to UTF-8. Now it shows boxes instead of question marks, but still not the correct characters. Also, I've ensured to set the encoding of the shp to UTF-8 when exporting the file, re-added the data store to geoserver, and republished the layer. But still not working, as in 1. still not showing the correct chinese characters 2. if label is set to columns with underscore in its name, the entire layer doesn't show
    – Sara
    Commented Mar 22, 2020 at 17:30
  • Are you using a font with Chinese characters in it?
    – Ian Turton
    Commented Mar 22, 2020 at 17:52
  • No, I am using all the same properties as in the cookbook, so my font is Arial.
    – Sara
    Commented Mar 23, 2020 at 0:37
  • By the way I've solve one of the problem. I found what is wrong with the underscore problem. I think it's because the column names in my data that have underscore exceeds 10 characters and Geoserver only excepts 10. So if I change postal_code to postal_cod, it works, and if I change school_name to school_nam, the layer shows, although the characters are still square because the data are Chinese characters.
    – Sara
    Commented Mar 23, 2020 at 0:47

1 Answer 1


Here's how my problem was eventually fixed. I made two key mistakes regarding the Chinese character problem (dbf encoding encoding setting in data store and font in sld), and one mistake regarding the underscore problem (column name length).

Chinese Character Problem

This is actually an encoding and font problem. The first mistake I made was not setting the dbf encoding when creating the data store of shp directories. To fix these mistakes, set the dbf encoding as in the image. In this case the correct encoding is utf8 (see figure).
Figure 1: setting the correct dbf encoding for the data store

The second mistake I made is using font Arial (the font from the cookbook), this caused the characters to appear as boxes. To fix this mistake, change the font to DFKai-SB, which is a font for Chinese characters. I didn't test with other fonts for Chinese characters, but I assume they will work as well.

(EDITED) Underscore Problem

This is actually a problem with the length of the column name of shp files. school_name and postal_code both have 11 characters. It seems shp will truncate after 10 characters. Opening the attribute table of the shp in QGIS, I found that the column names were school_nam and postal_nam. So the problem was fixed by changing <ogc:PropertyName> content to school_nam. Also, checking the Feature Type Details on GeoServer tells me the column names I should use (see figure).

note: The layer created from the csv in QGIS had the correct column names. But after exporting it as a shp and re-importing it to QGIS, I could see that the names were truncated. So take caution that the column names of the shp may be different from the original layer used to create it. enter image description here

  • 1
    Actually, it is shapefiles that truncate your field names to 10 chars - apparently it is a feature!
    – Ian Turton
    Commented Mar 23, 2020 at 10:07
  • 1
    Ahh, I see what you mean. I've just checked. The layer created from the csv had the correct attribute names. BUT after exporting to shp they were truncated. I unconsciously assumed the two layers would be the same, which lead me to think it was GeoServer that truncated the name. I'll edit my answer.
    – Sara
    Commented Mar 23, 2020 at 10:15
  • See gdal.org/drivers/vector/shapefile.html#creation-issues ~ Attribute names can only be up to 10 characters long. Starting with version 1.7, the OGR Shapefile driver tries to generate unique field names. Successive duplicate field names, including those created by truncation to 10 characters, will be truncated to 8 characters and appended with a serial number from 1 to 99
    – nmtoken
    Commented Apr 27, 2020 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.