It’s a bug of Camel[1] which has been fixed few weeks ago. [1]https://issues.apache.org/jira/browse/CAMEL-7971
-- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (English) http://jnn.iteye.com (Chinese) Twitter: willemjiang Weibo: 姜宁willem On November 18, 2014 at 11:32:30 AM, rvanluinen (rvanlui...@gmail.com) wrote: > I have been experimenting with Camel 2.14.0 and the REST DSL using the > servlet component. > I have followed the code in the example, however for reasons of my own I'd > like to use a different servlet name than the default of CamelServlet. This > works fine with vanilla servlet:/// URIs - add ?servletName=my-servlet and > all is good. > > To do this with the REST DSL I use the following: > > restConfiguration().component("servlet").endpointProperty("servletName", > "my-servlet"); > rest("/rest").post().otherDSLStatements; > > Contrary to what I thought, endpointProperty and not componentProperty sees > this property added to the URI. > > The problem is, it doesn't work. > I stepped through the code and it appears the problem is that the URI that > gets constructed for my post prior to being turned into a rest:// URI looks > something like: > servlet:///rest?httpMethodRestrict=POST?servletName=my-servlet. > > Which doesn't get correctly parsed by URISupport.parseQuery() since it > doesn't separate the second key/value pair using an ampersand ('&') as you > might expect. > > The code from ServletComponent looks like this (lines 194-197): > > String url = "servlet:///%s?httpMethodRestrict=%s"; > if (!query.isEmpty()) { > url = url + "?" + query; > } > > I can also confirm that using the debugger and changing the second '?' to > '&' results in the behaviour that I'd expect to see, which is that > my-servlet actually handles the request. > > I don't think I'm doing anything screwy here, can anyone else confirm > they've had similar problems or not? I think it's a bug but following > etiquette I'm posting here first and not raising issues in Jira immediately. > > Regards, > Rod > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Servlet-Component-with-REST-DSL-problem-in-URI-query-string-construction-tp5759228.html > > Sent from the Camel - Users mailing list archive at Nabble.com. >