springmvc-action.xml
<context:component-scan base-package="com.memsay.controller"/>
<context:component-scan base-package="com.memsay.service.*"/>
<context:component-scan base-package="com.memsay.dao.*"/>
jsp->js:调用后ajax,后台controller接收
$.ajax( {
type : 'GET',
contentType : 'application/json',
url : 'http://localhost:8080/com.memsay/getAllWords',
dataType : 'json',
data:'id=111&str=abc',
success : function(data) {
alert("success...");
@Controller
public class WordLearnController extends BaseController{
@Autowired
WordService ws;
@RequestMapping(value = "/getAllWords", method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> getAllWords() {
System.out.println("WordLearnController->getAllWords...");
List<Word> list = new ArrayList<Word>();
//
ws.getAllWords();
return null;//wordservice.getAllWords();
Controller 向下调用 service 与 dao 层
@Service //为了包扫描的时候这个Service被扫描到
public class WordServiceImpl implements WordService{
@Resouce
WordLearnDao wld;
//
public Map<String, Object>getAllWords() {
...
}
@Repository //为了包扫描的时候这个Dao被扫描到
public class WordLearnDaoImpl implements WordLearnDao{
@Resource
WordLearnDao wld;
public Map<String, Object>getAllWords() {
System.out.println("WordServiceImpl->getAllWords");
...
}
WordService与WordLearnDao为interface