Home >Web Front-end >HTML Tutorial >Please help, how to implement user permission judgment statement_html/css_WEB-ITnose

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

WBOY
WBOYOriginal
2016-06-24 12:03:401517browse

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;
}


}


回复讨论(解决方案)

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

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

Statement:
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