Spring MVC cascade attribute processing can not convert exception problem solving


This article mainly introduces the spring MVC cascade attribute processing can not be converted exception problem solving, this article through the example code is very detailed, for everyone’s study or work has a certain reference learning value, need friends can refer to

Two things to note,

1. In the mapper XML file, the corresponding cascade fields need to be filled in, such as

<insert useGeneratedKeys="true" keyProperty="id" parameterType="cn.taotao.bean.Admin">
 insert into tbl_admin ( name,password,email,lockFlag, role ) values ( #{name},#{password},#{email},#{lockFlag,jdbcType=INTEGER},#{role.id,jdbcType=INTEGER} )

Here, role is a role, an entity class, associated with the admin user.

When adding a user, you need to add a role as well. Here, the role is # {role. ID, JDBC type = integer}, which must be cascaded with an ID

2. In the foreground JSP page, the path attribute must also cascade with ID, such as

 <form:select path="role.id" items="${roles}" itemLabel="description" itemValue="id"  >

Here is the spring MVC tag. Path must be a concatenated field with ID

Otherwise, the report string type cannot be converted to an error report of role.

The above is the whole content of this article, I hope to help you learn, and I hope you can support developer more.

Recommended Today

Embedded development notes — debug component segger_ RTT

Author:zzssdd2 E-mail:[email protected] 1、 Preface In the process of embedded development, we often print out some debugging information to debug parameters and find problems. Usually, I use the chip’s serial port hardware device with serial port assistant software to debug. But the PCB hardware design of this project does not reserve serial port debugging interface, so […]