Spring MVC + Hibernate:将表单绑定到多态类列表

时间:2018-11-10 11:04:07

标签: spring hibernate spring-mvc polymorphism

我有这个结构类:

array (
  1 => 
  array (
    '1a' => 
    array (
      0 => 'test007',
      1 => 'test006',
      2 => 'test0094',
      3 => 'test0098',
      4 => 'test010',
      5 => 'test111',
      6 => 'test 008',
      7 => 'test112',
      8 => 'test004',
      9 => 'test002',
      10 => 'test001',
    ),
    23 => 
    array (
      0 => 'rg',
    ),
    '2a' => 
    array (
      0 => 'test001',
      1 => 'test003',
    ),
    'feh' => 
    array (
      0 => 'ndo',
    ),
    'wr' => 
    array (
      0 => 'fxv',
    ),
  ),
  2 => 
  array (
    '1a' => 
    array (
      0 => 'test',
    ),
    'b2' => 
    array (
      0 => 'gffff',
    ),
  ),
)

在控制器上:

server {
        root         /var/www/html/public;
        server_name [your_ip_address];
        index index.php;
        # Load configuration files for the default server block.
        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

## Laravel Production
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Content-Type-Options "nosniff";
        charset utf-8;
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
        location ~ /\.(?!well-known).* {
                deny all;
        }

        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }

}

此方法将列表连同所有B1和B2返回视图,并且全部确定。

但是当我尝试提交表单时:

public class A {
   private list<B> b;
}

public class B {}
public class B1 extends B{}
public class B2 extends B{}

每个类别的特定值不保存。

有什么办法吗?

0 个答案:

没有答案