1.比如项目中使用S.00001,S.00002来表示快修店的编号,可以使用mysql数据库字段的自增长列。

然后在java中将int类型转换成字符串。

/***
     * 根据id自增长生成服务商编号
     * @param id
     * @return
     */
    public static String getIdCode(Integer id){
        if(id>0 && id<10){
            return "S.0000"+id.toString();
        }else if(id>=10 && id<100){
            return "S.000"+id.toString();
        }else if(id>=100 && id<1000){
            return "S.00"+id.toString();
        }else if(id>=1000 && id<10000){
            return "S.0"+id.toString();
        }else if(id>=10000 && id<100000){
            return "S."+id.toString();
        }
        
        return "0";
    }

在后台添加快修店的时候,首先加载编号,然后设置文本框为disabled

<tr height="30">
        <td bgcolor="#f1f1f1">服务商编号:</td>
        <td align="left" class="bgf2"><input type="text" name="networkCode" id="networkCode" value="<%=idcode%>" disabled="disabled"/>
          <span class="fcRed" id="codeResult">*</span></td>    
        </tr>

但是在POST 方法传参 , HTML控件是 disabled="disabled"  将不会传参~!

可以在Action中同样的方法加载编号,然后添加到数据库中。(页面上的仅仅是显示)

相关文章:

  • 2021-12-13
  • 2021-05-17
  • 2021-11-27
  • 2022-12-23
  • 2021-11-02
  • 2022-02-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-05
  • 2022-12-23
  • 2021-11-27
  • 2021-08-18
  • 2022-02-22
相关资源
相似解决方案