Heim  >  Artikel  >  Web-Frontend  >  求帮助,怎么实现用户权限判断语句_html/css_WEB-ITnose

求帮助,怎么实现用户权限判断语句_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:03:401452Durchsuche

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;
/**
 * 用户登录
 */
@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;
}


}


回复讨论(解决方案)

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

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn