Please help, how to implement user permission judgment statement_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:03:40
Original
1490 people have browsed it

package com.sanqing.action;


import java.util.Map;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.sanqing.service.UserService;
/**
* User login
*/
@Controller("loginAction")
@Scope("prototype")
public class LoginAction extends ActionSupport {

@Resource
private UserService userService ;
private String username ;
private String password ;

@Override

public String execute() throws Exception {
if(!userService.login(username, password)) {
return this.INPUT;
}
else{
Map session = ActionContext.getContext().getSession();
session.put("user", userService.find(username));
}
return this.SUCCESS;


}





public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}


}


回复讨论(解决方案)

看不太懂你写的什么意思,验证用户是否登陆成功得查询数据库,顺便关联查询把用户权限一起查出来就行了呗!

看你的代码,好像只处理了判断用户名密码信息是否正确或是否已登录。跟权限相关的代码没有看到,权限一般跟角色有关系,然后某一个用户属于某一个角色。这里都看没有看到相关的内容。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template