java - Unable to use Scala and Spring MVC 3 to return JSON -


i converting java spring controller classes scala. in java, controller method returned json defined this:

@requestmapping(value = "/search", method = requestmethod.get) public @responsebody string[] searchfoods(@requestparam("term") string searchterm, principal principal) { ... } 

this works expected. same method in scala looks this:

@requestmapping(value = array("/search"), method = array(requestmethod.get)) def searchfoods(@requestparam("term") searchterm: string, principal: principal): java.util.list[string] @responsebody = { ... } 

however, time path requested following exception:

2011-10-09 09:06:19.980:warn::/searchpath/search.html javax.servlet.servletexception: not resolve view name 'searchpath/search' in servlet name 'dispatcher' @ org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet.java:1029) 

and web server returns http 500 error. possible use scala , spring mvc 3 return json?

looks putting @responsebody in wrong place. needs appear before method definition:

@requestmapping(value = array("/search"), method = array(requestmethod.get)) @responsebody def searchfoods(@requestparam("term") searchterm: string, principal: principal): java.util.list[string]  = { ... } 

i had tried before, forgot clean project. after moving annotation correct location, cleaning , rebuilding, working again. thanks!


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -