日期:2014-05-19 浏览次数:20838 次
package com.rec.action; import java.util.List; import javax.annotation.Resource; import com.opensymphony.xwork2.ActionSupport; import com.rec.model.Admin; import com.rec.model.User; import com.rec.service.UserService; @SuppressWarnings("serial") public class UserAction extends ActionSupport { private User user; private UserService userService; private String name; private List<User> userList; private String password; public User getUser() { return user; } // @Autowired public void setUser(User user) { this.user = user; } public UserService getUserService() { return userService; } public void setUserService(UserService userService) { this.userService = userService; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String login() { Admin admin=userService.login(name, password); user=userService.findById(admin.getUser_id()); if (admin != null&&user!=null) { return "SUCCESS"; } else return "ERROR"; } public String findAllUser(){ userList=userService.findAll(); if(userList!=null) return "SUCCESS"; else return "ERROR"; } public String delete(){ this.userService.delete(this.user); return "success"; } public List<User> getUserlist() { return userList; } public void setUserlist(List<User> userlist) { this.userList = userlist; } public List<User> getUserList() { return userList; } public void setUserList(List<User> userList) { this.userList = userList; } }
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'User.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <style> .tableborder { background: #4D76B3; border: 0px solid #4D76B3 } .altbg1 { background: #F3F6FA } .altbg2 { background: #FFFFFF } .STYLE5 {font-size: 12px; color: #FFFFFF; font-weight: bold; } .STYLE7 {font-size: 12px; color: #FFFFFF; font-weight: bold; font-family: Arial, Helvetica, sans-serif; } .STYLE8 { font-size: 11px; font-weight: bold; } .STYLE10 { font-size: 12px; color: #FFFFFF; } .STYLE12 {font-size: 12px} .STYLE14 {font-size: 12px; font-weight: bold; } .STYLE15 {font-we