我有一個階控制器:斯卡拉Spring Web MVC框架
@Controller
@RequestMapping(Array("/welcome"))
class HelloController{
@RequestMapping{val method = Array(RequestMethod.GET)}
def printWelcome(model: ModelMap) = {
println("IN: printWelcome(..)")
val greeting = new GreetingBean("Yo!", "Adam")
model.addAttribute("message", greeting);
"secure" // sends to the /jsf/secure.xhtml page
}
@RequestMapping{val value = Array("/greeting"), val method = Array(RequestMethod.GET)}
def greeting(model: ModelMap) = {
println("IN: greeting(..)")
val greeting = new GreetingBean("Greetings", "Davies")
model.addAttribute("greeting", greeting);
"greeting"; // sends to the /jsf/greeting.xhtml page
}
}
當我打電話http://localhost:8080/jsf-spring-guice/welcome
顯示在控制檯消息IN: printWelcome(..)
和正確的頁面導航到。
當我打電話http://localhost:8080/jsf-spring-guice/welcome/greeting
我得到一個404
錯誤。
我已經試過指定以不同的方式在問候方法@RequestMapping:
@RequestMapping{val value = Array("greeting"), val method = Array(RequestMethod.GET)}
@RequestMapping{val value = Array("/greeting")}
@RequestMapping(Array("/greeting"))
@RequestMapping(Array("/greeting"), Array(RequestMethod.GET))
和反編譯後生成的類,它總是看起來不錯。但是,我總是得到確定與歡迎,並總是202 /歡迎/問候
的反編譯的Scala類有這樣的:
@RequestMapping({"/welcome"})
這:
@RequestMapping(value={"/greeting"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
我看不出有任何理由爲什麼這不應該工作。誰能幫忙?
這是指定annotation..shouldn't的正確的方式它爲:'@RequestMapping(值=陣列(「/問候語」 ),method = Array(RequestMethod.GET)) –
HelloController.scala:31:error:not found:value method @RequestMapping(value = Array(「/ greeting」),method = Array(RequestMethod.GET)) ^ –