Servlet成员字段可能允许一个用户查看其它用户的数据

哈莱米修 发布于 2014/11/06 15:53
阅读 502
收藏 1
@SuppressWarnings("serial")
@Scope("prototype")
@Controller(value="powerRoleAction")
public class RoleAction extends BaseAction {
 
	private String roleId;
	
	@Resource(name="powerRoleService")
	private RoleService powerRoleService;
	
	private AdtFsRoleVO adtFsRoleVO;
	
	/** 
	  * @Title: index 
	  * @Description:角色信息模块索引函数
	  * @param @return
	  * @return String
	  * @throws 
	  */
	public String index(){
		return SUCCESS;
	}
	
	/** 
	  * @Title: getItems 
	  * @Description:获得角色列表 
	  * @param 
	  * @return void
	  * @throws 
	  */
	public void getItems(){
		Pagination pagination = null;
		try{
			if(adtFsRoleVO==null){
				adtFsRoleVO =new AdtFsRoleVO();
			}
			pagination = this.powerRoleService.getPageList(adtFsRoleVO, page, rows, sort, order);
		}catch(Exception e){
			e.printStackTrace();
		}
		List<AdtFsRoleVO> roleList = pagination.getList();
		JsonConfig config = new JsonConfig();   
		 config.setIgnoreDefaultExcludes(false);      
		 config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);    
//		 config.registerJsonValueProcessor(Date.class,new DateJsonValueProcessor("yyyy-MM-dd")); //date processor register   
		 config.setExcludes(new String[]{//只要设置这个数组,指定过滤哪些字段。   
		   
		 }); 
		try {
			String json=JSONSerializer.toJSON(roleList,config).toString();
			outJsonPlainString(response,"{\"total\":" + pagination.getTotalCount() + ",\"rows\":"+json + "}");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

公司代码扫描时报这样的错 : 类RoleAction  是独立的,因此成员字段adtFsRoleVo 可以在各个用户之间共享;导致结果是一个用户可以查看其它用户的数据。

try{
			if(adtFsRoleVO==null){
				adtFsRoleVO =new AdtFsRoleVO();
			}
			pagination = this.powerRoleService.getPageList(adtFsRoleVO, page, rows, sort, order);



说是   报这段adtFsRoleVO = new AdtFsRoleVO();的错误。。。

我是怎么看也感觉这没错,不知各位是否有很好的解决方法。。。。。。





加载中
0
景愿
景愿
该评论暂时无法显示,详情咨询 QQ 群:点此入群
哈莱米修
哈莱米修
回复 @景愿 : 恩恩。。我去试试
景愿
景愿
回复 @哈莱米修 : 代码检查始终是的死的。做参考就好, 不过我建议你把scope删掉,成员变量也删掉,用method内变量来处理就好。。。
哈莱米修
哈莱米修
恩恩。。我也是觉得这是没问题的,现在有点怀疑公司代码扫描系统的规则了,难道基于注解开发他就扫不出来,我去试试把scope恢复到配置文件中。。
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部