2
我正在使用Spring MVC,並且想要使用AJAX調用來獲取具有Person對象集合的JSON消息。 我有這樣的jQuery代碼:Spring MVC - AJAX/JSON - ResponseBody - >調用服務
$(document).ready(function() {
getAllPersons();
});
function getAllPersons() {
$.getJSON("person/allpersons", function(data) {
alert(data);
});
}
的人/ allpersons(REST URL)調用RequestMapping:
@RequestMapping(value="/allersons", method=RequestMethod.GET)
public @ResponseBody ??? ???() {
???
}
我有一個服務實現讓所有的人:
public interface IPersonService {
public Person addPerson(Person p);
...
public Set<Person> getAllPersons();
}
我怎樣才能撥打這項服務?那麼,我必須放置什麼,而不是?
我試了這樣的事情,但我在Eclipse IDE中出現錯誤:
public @ResponseBody <Set>Person getSomething() {
Set<Person> persons = IPersonService.getAllPersons();
return persons;
}
錯誤/警告:
The type parameter Set is hiding the type Set<E>
Cannot make a static reference to the non-static method getAllPersons() from the type IPersonService
The type Set is not generic; it cannot be parameterized with arguments <Person>
有什麼建議?
謝謝你提前&最好的問候。
我改變了它,我得到的服務電話多了一個錯誤:不能使靜態參考從類型IPersonService非靜態方法getAllPersons()。服務方法已經實現,我已經將它用於Adobe Flex前端和BlazeDS。但是我沒有在我的Java後端運行它。 (公共類PersonServiceImpl實現IPersonService ...它存在...) – Tim 2010-12-07 12:27:24