在控制器MessageController中注入IMessageService:
package com.gwolf.controller;
import ch.qos.logback.core.net.SyslogOutputStream;
import com.gwolf.service.IMessageService;
import com.gwolf.util.controller.AbstractBaseController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@RestController
public class MessageController extends AbstractBaseController{
@Resource
private IMessageService messageService;
@RequestMapping(value="/",
method = RequestMethod.GET)
public String idnex() {
return this.messageService.info();
}
@RequestMapping(value="/echo",
method = RequestMethod.GET)
public String echo(String mid) {
System.out.println("访问:" + super.getMessage("member.add.action"));
return super.getMessage("welcome.msg",mid);
}
}