Target Unreachable, identifier 'userInfoUpdateBean' resolved to null 错误问题描述以及解决

1、今天出现了一个问题,在点击用户信息修改的时候,出现如下的错误:

Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'userInfoUpdateBean' resolved to null,具体错误信息如下,其中项目是由JSF模板和Spring整合的:

​
严重: Error Rendering View[/pages/user/userInfoUpdate.xhtml]
javax.el.PropertyNotFoundException: /pages/user/userInfoUpdate.xhtml @36,65 value="#{userInfoUpdateBean.sex}": Target Unreachable, identifier 'userInfoUpdateBean' resolved to null

​

2、开始定位问题,从页面看下有没有问题,为啥这个userInfoUpdateBean为空呢,类名为UserInfoUpdateBean,然后再去找bean的配置文件,如下所示:

	<bean id="userInfoUpdateBean" scope="view"
		class="com.user.info.bean.userInfoUpdateBean"
		init-method="init">
		<property name="userInfoServiceI">
			<ref bean="userInfoServiceImpl" />
		</property>
	</bean>

这里也没有问题呀,再去类底下看是不是setSex方法里面的属性写成大写了,发现也没有问题,添加多一个无参的构造方法都没用,还是依旧报错。后面想想是不是被拦截了,发现也没被拦截器拦截呀。

3、去找资料,改着试了几个小时都没用,最后,用另外一种方法,把界面报错的给注释掉,然后一步步看,到底问题是出现在哪里,后面发现,只有两个有单选框的标签才会出现这种问题,把我坑得不要不要的,顿时觉得自己好菜鸡,单选框原先是这样写的:

<p:selectOneRadio id="sex" initSelectItemLabel="男" value="#{userInfoUpdateBean.sex}">
    <f:selectItem itemLabel="男" itemValue="男" />
    <f:selectItem itemLabel="女" itemValue="女" />
</p:selectOneRadio>

4、就是因为这个selectOneRadio这个标签的initSelectItemLabel属性,给这个加了个属性,就会报上面的错误,最后去掉这个属性,便不会报这个错误了,最后代码如下:

​
<p:selectOneRadio id="sex" value="#{userInfoUpdateBean.sex}">
    <f:selectItem itemLabel="男" itemValue="男" />
    <f:selectItem itemLabel="女" itemValue="女" />
</p:selectOneRadio>

​

5、以上就是我所遇到的坑,在这里积累一下,以免大家也遇到这个问题!

猜你喜欢

转载自blog.csdn.net/u012561176/article/details/81634320