1:编写获得下一个编号的方法
//获取编号的next值
private static String nextId = "";
public static String getNextId(String curId, String pattern) {
String curNum = curId.substring(curId.lastIndexOf("_") + 1);
Integer nextNum = Integer.parseInt(curNum) + 1;
DecimalFormat df = new DecimalFormat(pattern);
nextId = curId.substring(0, curId.lastIndexOf("_") + 1)
+ df.format(nextNum);
return nextId;
}:
2:操作数据库
<span style="white-space:pre"><span style="white-space:pre"> </span>//执行保存或更新动作 </span>
<span style="white-space:pre"> </span>public void saveOrUpdate(Product product) {
<span style="white-space:pre"> </sp