java.lang.NullPointerException
at com.sunwave.action.privilege.UserAction.findUserPageInfo(UserAction.java:78)省略N字
框架:SSH,service在Action中注入,配置文件如下:
<!--用户管理-->
<bean id="userAction" class="com.sunwave.action.privilege.UserAction" scope="prototype">
<property name="userService" ref="userService"/>
<property name="systemParameterService" ref="systemParameterService"></property>
</bean>
<bean id="userService" class="com.sunwave.service.impl.privilege.UserServiceImpl"
parent="baseService">
<property name="roleService" ref="roleService"/>
<property name="empService" ref="empService"/>
<property name="systemParameterService" ref="systemParameterService"/>
<property name="userDao"><ref bean="userDao"/></property>
</bean>
<bean id="userDao" class="com.sunwave.dao.impl.privilege.UserDaoHibImpl"
parent="baseDAO">
</bean>
一般情况下,不会出现该错误,系统发布到公网后偶现,初步怀疑是高访问量的并发性错误,怀疑是否和service的单例模式有关,求解~~javassh并发
at com.sunwave.action.privilege.UserAction.findUserPageInfo(UserAction.java:78)省略N字
框架:SSH,service在Action中注入,配置文件如下:
<!--用户管理-->
<bean id="userAction" class="com.sunwave.action.privilege.UserAction" scope="prototype">
<property name="userService" ref="userService"/>
<property name="systemParameterService" ref="systemParameterService"></property>
</bean>
<bean id="userService" class="com.sunwave.service.impl.privilege.UserServiceImpl"
parent="baseService">
<property name="roleService" ref="roleService"/>
<property name="empService" ref="empService"/>
<property name="systemParameterService" ref="systemParameterService"/>
<property name="userDao"><ref bean="userDao"/></property>
</bean>
<bean id="userDao" class="com.sunwave.dao.impl.privilege.UserDaoHibImpl"
parent="baseDAO">
</bean>
一般情况下,不会出现该错误,系统发布到公网后偶现,初步怀疑是高访问量的并发性错误,怀疑是否和service的单例模式有关,求解~~javassh并发
解决方案 »
- 有关JMX的一些问题
- Acegi怎么实现“让系统忘记我”?
- 急急急!!!上传图像插件
- 关于spring的配置
- spring的3个小问题 . 30分
- J2EE高手们,我用Hibernate怎么老是出现PropertyNotFoundException异常,是为什么啊?谢谢!
- 查询给定HQL的总记录数问题
- log4j的问题:
- 如何调整JB8中的光标???高分!!!!
- 关于spring中用xml文件读取.properties报错的问题
- org.apache.jasper.JasperException: java.lang.ClassCastException: org.apache.stru
- spring 3.4的jar包在官网哪里下载
比如at com.sunwave.action.privilege.UserAction.findUserPageInfo(UserAction.java:78) 这一块的代码
Map session = ActionContext.getContext().getSession();
user.setUserLevel((Integer)session.get(USER_LEVEL));
user.setLcId((Integer)session.get(USER_ID));
Integer userType = (Integer)session.get(USER_TYPE);
user.setCpUserType(userType);
if((user.getUserLevel().equals(Common.SUPER_USER_LEVEL) || user.getUserLevel().equals(Common.SYSTEM_ADMIN_LEVEL))
&& userType.equals(Common.COMPANY_USER_TYPE)){
}else{
user.setUserType(userType);
}
user.setCpTopId((Integer)session.get(Common.USER_TOPID));
if(user.getCorpId()== null)
user.setCorpId((Integer)session.get(Common.USER_COMPANYID));
infoMap=userService.findUserByCon(start,limit,user);
return SUCCESS;
}
......
infoMap=userService.findUserByCon(start,limit,user);你这个action我至少看到了两个存在安全隐患。1. Struts已经不建议在action里通过ActionContext.getContext()获取session了。官方已经说,可能会出现为空现象,可以到官网看康。
2.使用userService前应该判断下是否为空,这是良好的编程习惯。
2.从安全角度,userService是该先判断null,但是正常逻辑,spring注入service是不会为空的,总不能因为某些地方BUG而加一段空判断的冗余代码吧