public static String getUuid() {
String s = UUID.randomUUID().toString();
// 去掉"-"符号的UUID
return s.replace("-", "").trim();
}数据库
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)//针对数据库 主键自动增加的
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid",strategy="uuid")//使用uuid的主键注解 dom
使用UUID 出现detached entity passed to persist 这种错误是由于你的主键id已经有值了 因此报错 在jsp页面不要定义他namejsp