2
2
3
3
import java .io .BufferedReader ;
4
4
import java .io .IOException ;
5
+ import java .io .UnsupportedEncodingException ;
6
+ import java .net .URLDecoder ;
5
7
import java .util .Enumeration ;
6
8
import java .util .Map ;
7
9
import java .util .TreeMap ;
@@ -21,6 +23,7 @@ public class RestServlet extends HttpServlet {
21
23
private static final Logger logger = Logger .getLogger (RestServlet .class );
22
24
23
25
private static final long serialVersionUID = 1L ;
26
+ private static final String UTF8 = "UTF-8" ;
24
27
25
28
public static final String GET = "GET" ;
26
29
public static final String PUT = "PUT" ;
@@ -132,15 +135,16 @@ protected String getBody(final HttpServletRequest request, final String requestM
132
135
/**
133
136
* @param request the current request.
134
137
* @return the query parameters, as a map.
138
+ * @throws UnsupportedEncodingException
135
139
*/
136
- protected Map <String , String > getQueryParams (final HttpServletRequest request ) {
140
+ protected Map <String , String > getQueryParams (final HttpServletRequest request ) throws UnsupportedEncodingException {
137
141
String queryString = notNullString (request .getQueryString ());
138
142
Map <String , String > queryParams = new TreeMap <>();
139
143
String [] split = queryString .split ("&" );
140
144
for (String string : split ) {
141
145
String [] strings = string .split ("=" );
142
146
if (strings .length == 2 ) {
143
- queryParams .put (strings [0 ], strings [1 ]);
147
+ queryParams .put (URLDecoder . decode ( strings [0 ], UTF8 ), URLDecoder . decode ( strings [1 ], UTF8 ) );
144
148
}
145
149
}
146
150
return queryParams ;
0 commit comments