package ies.io.controller;
import ies.io.domain.Account;
import ies.io.service.AccountService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/account")
public class AccountController {
/**
* 当service的实现写完后,回到控制层
*
* @Resource(name="accountServiceImpl") private AccountService as;
* 在我看来这2句和在一起就等于 AccountService as =
* new accountServiceImpl();
* @param req
* @return
*/
@Resource(name = "accountServiceImpl")
private AccountService as;
@RequestMapping("/add")
public String addAccount(HttpServletRequest req) {
Account acc = new Account();
acc.setName(req.getParameter("name"));
as.addAccount(acc);
req.setAttribute("key", "hzjw");
return "hzjw";// "hzjw"这个String 类型就是hzjw.jsp的名字只要名字一样那么就一定能找到
}
}