困扰好几天的问题,请大家帮忙解决下,谢谢!

ldzywxj 2009-10-30 03:36:02
开发环境:Struts1.x+Hibernate3.x+Spring Tomcat5.5
页面报错(表单提交后在Action中设置断点不进入断点):

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jb.common.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:32)


root cause

java.lang.IllegalArgumentException: No bean specified
org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptor(PropertyUtils.java:837)
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:934)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jb.common.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:32)

JSP代码:

<html:form method="post" action="second">
<html:hidden property="o" value="doAdd" />
<table width="100%">
<tr>
<td>
<font color="#0000CC">您正在做的业务是:人力资源--客户化设置--人力资源档案管理设置--II级机构设置
</font>
</td>
</tr>
</table>

<table width="100%" border="1" cellpadding=0 cellspacing=1

class="input_table">
<tr>
<td width="19%" class="input_title">
I级机构名称
</td>
<td width="81%" class="input_content">
<!-- 从数据库中读取I级机构列表 -->
<html:select property="item.configFileFirstKind.firstKindId">
<html:optionsCollection name="FIRSTS_OPTIONS" label="firstKindName"
value="firstKindId" />
</html:select>
</td>
</tr>

<tr>
<td class="input_title">
II级机构名称
</td>
<td class="input_content">
<html:text property="item.secondKindName"/>

</td>
</tr>
<tr>
<td class="input_title">
薪酬发放责任人编号(多个编号之间请用"半角逗号"加"一个空格"隔开,如", ")
</td>
<td class="input_content">
<html:textarea property="item.secondSalaryId" rows="4"></html:textarea>

</td>
</tr>
<tr>
<td class="input_title">
销售责任人编号(多个编号之间请用"半角逗号"加"一个空格"隔开,如", ")
</td>
<td class="input_content"><html:textarea property="item.secondSaleId" rows="4"></html:textarea>

</td>
</tr>
</table>
<div class="button_bar">
<html:submit>保 存</html:submit>
<html:cancel>返 回</html:cancel>
</div>
<script>
build_validate("item.secondKindName","II级机构名不能为空","Limit","1","50");
</script>
</html:form>

ActionForm代码:

public class SecondKindForm extends BaseForm {

ConfigFileSecondKind item = new ConfigFileSecondKind();

public ConfigFileSecondKind getItem() {
return item;
}

public void setItem(ConfigFileSecondKind item) {
this.item = item;
}
}


applicationContext.xml中的配置:

<bean name="/second" class="org.jb.y272.team0.web.action.SecondKindAction">
<property name="secondBiz">
<ref bean="secondBiz" />
</property>
<property name="firstBiz">
<ref bean="firstBiz" />
</property>
</bean>

如果有什么问题没描述清楚,请说明。
...全文
220 31 打赏 收藏 转发到动态 举报
写回复
用AI写文章
31 条回复
切换为时间正序
请发表友善的回复…
发表回复
ldzywxj 2009-10-30
  • 打赏
  • 举报
回复
感谢 楼上的帮忙!

private ConfigFileFirstKind configFileFirstKind = new ConfigFileFirstKind();

问题解决
lyjilu2008 2009-10-30
  • 打赏
  • 举报
回复
看你的错误像是页面 name值的类型和你actionForm 里面的类型不同,在struts收集表单数据时包错,当然进不到Action。
ldzywxj 2009-10-30
  • 打赏
  • 举报
回复
实现功能:

增加II级机构(同时设置上对应的I级机构)。

其中II级机构与I级机构为单向的多对一映射。
默默_XL 2009-10-30
  • 打赏
  • 举报
回复
帮顶个先 再慢慢看看能帮你不```
ldzy2007 2009-10-30
  • 打赏
  • 举报
回复
谁能远程帮我看下???

QQ:81052376 验证:javaee
ldzywxj 2009-10-30
  • 打赏
  • 举报
回复
applicationContext.xml中的配置:

<?xml version="1.0" encoding="UTF-8"?>
<!--<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" -->
<!--" http://www.springframework.org/dtd/spring-beans.dtd"> -->

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>

<bean id="myHibTxManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="myHibTxManager">
<tx:attributes>
<!-- 对get/load/search开头的方法要求只读事务 -->
<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
<tx:method name="load*" propagation="SUPPORTS" read-only="true" />
<tx:method name="search*" propagation="SUPPORTS" read-only="true" />
<!-- 对其它方法要求事务 -->
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes >
</tx:advice>
<aop:config>
<!--
只对GoodsBiz添加事务支持,因为前面配置的transactionManager
是专对Hibernate的事务管理器 。
-->
<aop:pointcut id="serviceMethods"
expression="execution(* org.jb.y272.team0.biz.*.*(..))" />
<!-- 织入 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" />
</aop:config>
<!-- 1. DAO -->
<bean id="commonDAO"
class="org.jb.common.dao.hibimpl.CommonDAOHibImpl">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>


<!-- 2. BIZ -->
<bean id="rightBiz"
class="org.jb.y272.team0.biz.RightBiz">
<property name="commonDAO">
<ref local="commonDAO" />
</property>
</bean>
<bean id="userBiz"
class="org.jb.y272.team0.biz.UserBiz">
<property name="commonDAO">
<ref local="commonDAO" />
</property>
</bean>
<bean id="roleBiz"
class="org.jb.y272.team0.biz.RoleBiz">
<property name="commonDAO">
<ref local="commonDAO" />
</property>
</bean>

<bean id="firstBiz"
class="org.jb.y272.team0.biz.ConfigFileFirstKindBiz">
<property name="commonDAO">
<ref local="commonDAO" />
</property>
</bean>
<bean id="secondBiz"
class="org.jb.y272.team0.biz.ConfigFileSecondKindBiz">
<property name="commonDAO">
<ref local="commonDAO" />
</property>
</bean>

<!-- 3. Action -->
<bean name="/right" class="org.jb.y272.team0.web.action.RightAction">
<property name="rightBiz">
<ref bean="rightBiz" />
</property>
</bean>
<bean name="/user" class="org.jb.y272.team0.web.action.UserAction">
<property name="userBiz">
<ref bean="userBiz" />
</property>
<property name="roleBiz">
<ref bean="roleBiz" />
</property>
</bean>
<bean name="/role" class="org.jb.y272.team0.web.action.RoleAction">
<property name="roleBiz">
<ref bean="roleBiz" />
</property>
</bean>
<bean name="/home" class="org.jb.y272.team0.web.action.HomeAction">
</bean>
<bean name="/first" class="org.jb.y272.team0.web.action.FirstKindAction">
<property name="firstBiz">
<ref bean="firstBiz" />
</property>
</bean>
<bean name="/second" class="org.jb.y272.team0.web.action.SecondKindAction">
<property name="secondBiz">
<ref bean="secondBiz" />
</property>
<property name="firstBiz">
<ref bean="firstBiz" />
</property>
</bean>
</beans>
ldzywxj 2009-10-30
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 gukuitian 的回复:]
<html:select property="item.configFileFirstKind.firstKindId">                    

还是
??

<html:select property="item.firstKindId">                       
[/Quote]

是<html:select property="item.configFileFirstKind.firstKindId">

因为BEAN ConfigFileSecondKind中只有

private ConfigFileFirstKind configFileFirstKind;

而firstKindId是ConfigFileFirstKind 的属性。
ldzywxj 2009-10-30
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 zhangwenmin 的回复:]
这个我遇到过,是jsp页面用struts标签出错了可能是关于bean的标签!
[/Quote]

请问后来你是如何解决的?
ldzy2007 2009-10-30
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 ima 的回复:]
你的action配置在spring中了,不是通过struts的配置文件配置的?
如果是那样,当然找不到second这个action啊,唉
[/Quote]

Struts与hibernate都整合到了spring中管理。查询出列表没有问题,只是新增时出现上面的错误

ldzy2007 2009-10-30
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 swandragon 的回复:]
SecondKindAction
怎么写的啊?
贴下代码
[/Quote]


public class SecondKindAction extends BaseAction {

private ConfigFileSecondKindBiz secondBiz ;
private ConfigFileFirstKindBiz firstBiz;

public ConfigFileSecondKindBiz getSecondBiz() {
return secondBiz;
}

public void setSecondBiz(ConfigFileSecondKindBiz secondBiz) {
this.secondBiz = secondBiz;
}

/**
* 跳转到新增页面
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward toAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
SecondKindForm myForm = (SecondKindForm)form;

//解决页面中item.configFileFirstKind.firstKindId中configFileFirstKind为NULL
ConfigFileSecondKind item = myForm.getItem();

if (null==item.getConfigFileFirstKind()){
item.setConfigFileFirstKind(new ConfigFileFirstKind());
}
myForm.setItem(item);

//查询出I级机构列表
List firsts = super.getFirsts(this.getServlet().getServletConfig().getServletContext(), this.firstBiz);
request.setAttribute("FIRSTS_OPTIONS", firsts);

return mapping.findForward("add");
}

/**
* 执行新增
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws IOException
*/
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException
{
SecondKindForm myForm = (SecondKindForm)form;

this.getSecondBiz().add(myForm.getItem());

response.sendRedirect("second.do?o=list");

return null;
}
/**
* 显示数据所有列表
* @param mapping
* @param form
* @param request
* @param messages
* @return
*/
public ActionForward list(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)

{
SecondKindForm myForm = (SecondKindForm)form;
this.getSecondBiz().getList(myForm.getItem(), myForm.getPageResult());

return mapping.findForward("list");
}

public ConfigFileFirstKindBiz getFirstBiz() {
return firstBiz;
}

public void setFirstBiz(ConfigFileFirstKindBiz firstBiz) {
this.firstBiz = firstBiz;
}
ldzy2007 2009-10-30
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 warison2008 的回复:]
No bean specified,明显是struts标签引入的name 或property不存在,好好检查下你得
ConfigFileSecondKind.java
[/Quote]


private int secondKindId;
private String secondKindName;
private String secondSalaryId;
private String secondSaleId;

private ConfigFileFirstKind configFileFirstKind;

public ConfigFileFirstKind getConfigFileFirstKind() {
return configFileFirstKind;
}

public void setConfigFileFirstKind(ConfigFileFirstKind configFileFirstKind) {
this.configFileFirstKind = configFileFirstKind;
}

public int getSecondKindId() {
return secondKindId;
}

public void setSecondKindId(int secondKindId) {
this.secondKindId = secondKindId;
}

public String getSecondKindName() {
return secondKindName;
}

public void setSecondKindName(String secondKindName) {
this.secondKindName = secondKindName;
}

public String getSecondSalaryId() {
return secondSalaryId;
}

public void setSecondSalaryId(String secondSalaryId) {
this.secondSalaryId = secondSalaryId;
}

public String getSecondSaleId() {
return secondSaleId;
}

public void setSecondSaleId(String secondSaleId) {
this.secondSaleId = secondSaleId;
}

ldzywxj 2009-10-30
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 yingkeda 的回复:]
你先看你那个断点是不是点到标签里去了,然后在标签里面出不来,再看看你的这个断点优先级是不是低,也就是说其他的高然后吧这个忽略掉了!
action="second">
你试试  action="/second">  看怎么样?

[/Quote]

我是在Action中加的断点,只有一个断点。

<html:form action="/second">是错误的

<form action="second.do"> 与<form action="/second"> 作用一样的
ldzywxj 2009-10-30
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wangju309 的回复:]
服务器启动工程时报错没?配置文件检查下吧
[/Quote]

启动服务器没有错,能正常显示出列表,但新增时出现上面的错误。

I级机构名称 II级机构名称 薪酬发放责任人编号 销售责任人编号 变更 删除
学院 x 1 1 变更 删除
学院 y 1 1 变更 删除
ldzywxj 2009-10-30
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 ima 的回复:]
把你的web.xml、struts的配置文件贴上来看看


肯定是你的struts根本就没找到second这个action,而没找到的原因就是你没配置
[/Quote]

web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>SetCharacterEncodingFilter</filter-name>
<filter-class>org.jb.common.filter.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SetCharacterEncodingFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>SetCharacterEncodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet>
<servlet-name>action_tmp</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>


struts-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="userForm" type="org.jb.y272.team0.web.form.UserForm" />
<form-bean name="roleForm" type="org.jb.y272.team0.web.form.RoleForm" />
<form-bean name="rightForm" type="org.jb.y272.team0.web.form.RightForm" />
<form-bean name="firstKindForm" type="org.jb.y272.team0.web.form.FirstKindForm" />
<form-bean name="secondKindForm" type="org.jb.y272.team0.web.form.SecondKindForm" />
<form-bean name="baseForm" type="org.jb.common.web.form.BaseForm" />

</form-beans>

<action-mappings>
<action path="/home" parameter="o" scope="session"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="header" path="/WEB-INF/jsp/home/header.jsp" />
<forward name="footer" path="/WEB-INF/jsp/home/footer.jsp" />
<forward name="menu" path="/WEB-INF/jsp/home/menu.jsp" />
<forward name="welcome" path="/WEB-INF/jsp/home/welcome.jsp" />
</action>
<action name="userForm" path="/user" parameter="o"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="list" path="/WEB-INF/jsp/user/list.jsp" />
<forward name="add" path="/WEB-INF/jsp/user/add.jsp" />
<forward name="edit" path="/WEB-INF/jsp/user/edit.jsp" />
<forward name="detail" path="/WEB-INF/jsp/user/detail.jsp" />
<forward name="assign_role"
path="/WEB-INF/jsp/user/assign_role.jsp" />
</action>
<action name="roleForm" path="/role" parameter="o"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="add" path="/WEB-INF/jsp/role/add.jsp" />
<forward name="edit" path="/WEB-INF/jsp/role/edit.jsp" />
<forward name="list" path="/WEB-INF/jsp/role/list.jsp" />
<forward name="assign_rights"
path="/WEB-INF/jsp/role/assign_rights.jsp" />
</action>
<action attribute="rightForm"
name="rightForm" parameter="o" path="/right" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="add" path="/WEB-INF/jsp/rights/add.jsp" />
<forward name="edit" path="/WEB-INF/jsp/rights/edit.jsp" />
<forward name="list" path="/WEB-INF/jsp/rights/list.jsp" />
</action>


<action input="/WEB-INF/jsp/home/top.jsp" name="baseForm"
path="/main" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy"
validate="false">
<forward name="top" path="/WEB-INF/jsp/main/index_top.html" />
<forward name="left"
path="/WEB-INF/jsp/main/index_left.jsp" />
<forward name="right"
path="/WEB-INF/jsp/main/index_right.htm" />
<forward name="bottom"
path="/WEB-INF/jsp/main/index_bottom.jsp" />
</action>

<action name="firstKindForm" path="/first" parameter="o"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="list" path="/WEB-INF/jsp/config/file/first_kind.jsp" />
<forward name="add" path="/WEB-INF/jsp/config/file/first_kind_register.jsp" />

</action>

<action name="secondKindForm" path="/second" parameter="o"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="list" path="/WEB-INF/jsp/config/file/second_kind.jsp" />
<forward name="add" path="/WEB-INF/jsp/config/file/second_kind_register.jsp" />

</action>

</action-mappings>
<message-resources
parameter="org.jb.y272.team0.ApplicationResources" />
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="classpath:applicationContext.xml" />
</plug-in>

</struts-config>
imA 2009-10-30
  • 打赏
  • 举报
回复
把你的web.xml、struts的配置文件贴上来看看


肯定是你的struts根本就没找到second这个action,而没找到的原因就是你没配置
imA 2009-10-30
  • 打赏
  • 举报
回复
你的action配置在spring中了,不是通过struts的配置文件配置的?
如果是那样,当然找不到second这个action啊,唉
swandragon 2009-10-30
  • 打赏
  • 举报
回复
也有可能是bean类中有属性没有new
zhangwenmin 2009-10-30
  • 打赏
  • 举报
回复
这个我遇到过,是jsp页面用struts标签出错了可能是关于bean的标签!
道光2008 2009-10-30
  • 打赏
  • 举报
回复
No bean specified,明显是struts标签引入的name 或property不存在,好好检查下你得
ConfigFileSecondKind.java
swandragon 2009-10-30
  • 打赏
  • 举报
回复
SecondKindAction
怎么写的啊?
贴下代码
加载更多回复(11)

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧