Spring3+mybatis+mysql整合详解(五)
下面来看java代码:
1、Control层代码:
?
- package?com.hl.usersmanager.controller; ??
- ??
-
import?java.util.List; ??
- ??
-
import?org.springframework.beans.factory.annotation.Autowired; ??
-
import?org.springframework.stereotype.Controller; ??
-
import?org.springframework.ui.ModelMap; ??
-
import?org.springframework.web.bind.annotation.RequestMapping; ??
- ??
-
import?com.hl.usersmanager.model.Users; ??
-
import?com.hl.usersmanager.service.IUserService; ??
- ??
-
@Controller??
-
public?class?UserController?{ ??
-
??
-
????@Autowired??
-
????private?IUserService?userService; ??
- ??
-
????@RequestMapping(value?=?"findUserByName.do") ??
-
????public?String?findUserByName(String?name,ModelMap?model)?{ ??
- ????????Users?users?=?userService.findUserByName(name); ??
-
????????model.addAttribute("userPhone",users.getPhone()); ??
-
????????System.out.println("userPhone:"?+?users.getPhone()); ??
-
????????return?"showUser"; ??
- ????} ??
- ???? ??
- ????…… ??
- }??
package com.hl.usersmanager.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.s