package com.test.ssh.controller;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.RequestAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.opensymphony.xwork2.ActionSupport;
import com.test.ssh.domain.User;
import com.test.ssh.service.UserService;
@Controller
public class UserController {
/**
*
*/
private static final long serialVersionUID = 1L;
@Resource(type=UserService.class)
private UserService userService;
//@Resource(type=UserService.class)
public void setUserService(UserService userService) {
this.userService = userService;
}
/*
@RequestMapping("/hello")
public ModelAndView hello() {
System.out.println("hello1");
ModelAndView view = new ModelAndView("success");
System.out.println("hello2");
List<User> userList = userService.getUsers();
// view.addObject("userList", userList);
// Logger log = LogManager.getLogger(this.getClass().getName());
// log.info("hello world");
if(userList!=null)
{
System.out.println(userList.size());
}
else{
System.out.println("error");
}
return view;
}*/
@RequestMapping("/hello")
public ModelAndView hello() {
System.out.println("hello1");
ModelAndView view = new ModelAndView("success");
System.out.println("hello2");
List<User> userList = userService.getUsers();
// view.addObject("userList", userList);
// Logger log = LogManager.getLogger(this.getClass().getName());
// log.info("hello world");
//if(userList!=null)
//{
// System.out.println(userList.size());
//}
//else{
// System.out.println("error");
// }
return view;
}
}
评论0
最新资源