junit 安装 springmvc+hibernate(16)

电脑杂谈  发布时间:2018-02-07 19:32:08  来源:网络整理

</welcome-file-list>

</web-app>

控制层UserController

package com.controller;

import java.util.List;

import org.apache.log4j.Logger;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.ui.ModelMap;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

import com.entity.AcctUser;

import com.service.UserService;

@Controller

public class UserController {

private static final Logger LOGGER = Logger.getLogger(UserController.class);

@Autowired

private UserService userService;

@RequestMapping("/showInfo/{userId}")

public String showUserInfo(ModelMap modelMap, @PathVariable String userId){

LOGGER.info("查询用户:" + userId);

AcctUser userInfo = userService.load(userId);

modelMap.addAttribute("userInfo", userInfo);

return "/user/showInfo";

}

@RequestMapping("/showInfos")

public @ResponseBody List<AcctUser> showUserInfos(){

LOGGER.info("查询用户全部用户");

List<AcctUser> userInfos = userService.findAll();

return userInfos;

}

}

接下来。访问测试咯!!!!只是简单记录下,可能有些没有考虑周全


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/ruanjian/article-65857-16.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 付亚静
      付亚静

      西方列强普遍认为北阳水师可以轻松战胜日本海军

    热点图片
    拼命载入中...