Can't Spring MVC receive what you entered in the data grid?

Asked 2 years ago, Updated 2 years ago, 84 views

A screen consisting of a header and a datagrid is created with Spring MVC.
However, I cannot accept the contents entered in the data grid.

I wrote a code like this

@RequestMapping(value="/updateList")
public ModelAndView updateList (Condition condition, Grid[]grid) {

Can Spring MVC receive the data grid input?
I looked it up for about two days, but I couldn't find out orz

Screen image Enter a description of the image here

Error Contents

org.springframework.web.util.NestedServletException:Request processing failed;nested exception is
org.springframework.beans.BeanInstantationException: Failed to instantiate
[[Ljp.co.test.server.arrival.form.WEB_AR_INP_010_Form$Grid;]:
No default constructor found; nested exception is
java.lang.NoSuchMethodException:
[Ljp.co.test.server.arrival.form.WEB_AR_INP_010_Form$Grid;.()
org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:978)
org.springframework.web.servlet.FrameworkServlet.doPost (FrameworkServlet.java:868)
javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
jp.co.test.server.framework.WebFilter.exec (WebFilter.java:79)
jp.co.test.server.framework.WebFilter.doFilter(WebFilter.java:74)

Where did the exception "L.jp.co.test" L come from?
In the first place, something is wrong at the root, so I feel like Spring has added an L.

java spring

2022-09-30 15:49

1 Answers

The error seems to have been caused by two method arguments.
I summarized it into one Bean and found no errors.

@RequestMapping(value="/updateList")    
public ModelAndView updateList (Condition condition) rows IOException {
@Data
public class Condition implements Serializable {
    private String remaks;
    private List <Grid>grid;
}

@ Data
public class Grid implements Serializable {
    private Integer rowNo;
    private String prodCode;
}

Also, I made my own Grid, but I set the input id/name as follows:

<input type="text" id="grid[0].prodCode" name="grid[0].prodCode">
   <input type="text" id="grid[1].prodCode" name="grid[1].prodCode">
   <input type="text" id="grid[2].prodCode" name="grid[2].prodCode">

That's all I did.


2022-09-30 15:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.