Jersey matches regex pattern before the method type -
is possible define 2 methods in jersey same regex different type? (get, put ..):
@get @path("{key: .+}") @produces(mediatype.text_plain) public response root(string key) { } @put @path("{key: .+}") @consumes(mediatype.multipart_form_data) @produces(mediatype.text_plain) public response publish(string key, formdatamultipart data) { } the first method should reply key (with or without slashes)
curl -x "http://localhost/key jersey respond 200 ok since went method curl -x "http://localhost/key/ jersey respond 200 ok since went method curl -x put -t file.txt "http://localhost/key jersey respond 200 ok since went put method curl -x put -t file.txt "http://localhost/key/ jersey respond 200 ok since went put method curl -x put -t file.txt "http://localhost/key/folder/folder jersey respond 405 method not found since went method instead of put (the respond 1 folder level 'key' expected jersey go directly put since suppose check method type before regex matching why last 1 doesn't work? seems jersey first looks regex though it's put request.
you "jersey respond 405 method not found since went method instead of put" 405 means didn't go method. try changing put method to:
@put @path("{key: .+}") @produces(mediatype.text_plain) public response publish(string key) { } and should work. need ensure provide correct data part of curl request ensure matches @consumes annotation when put in request.
Comments
Post a Comment