int youNumber = 1; // 0 代表前面补充0 // 3 代表长度为3 // d 代表参数为正数型 String str = String.format("%03d", youNumber); System.out.println(str); // 0001
<h2>数字格式化</h2><p>java.text.NumberFormat</p><p>示例:</p><p>NumberFormat NumFmt = NumberFormat.getInstance();</p><p>NumFmt.setMaximumFractionDigits(0);</p><p>NumFmt.setMinimumIntegerDigits(2);</p><p>System.<span style="color:rgb(0,0,192);">out</span>.println(NumFmt.format(80934.234));<span style="color:rgb(63,127,95);">//80,934</span></p>
页面js:
XControl.ruleGroup.rules = { id:4, officeId:"can911", airCode:"cx", channels:[{ channel: 'User list', groupId: 4, rules: [ {id: 1, channel: 'Anne'}, {id: 2, channel: 'Amelie'} ]},{ channel: 'User list', groupId: 4, rules: [ {id: 1, channel: 'Anne'}, {id: 2, channel: 'Amelie'} ]}]}; //将JSON数组格式化,这一步是必要的 var xControlVO = JSON.stringify(XControl.ruleGroup.rules); //特殊符号保存不了问题 var result = ""; for(var i=0;i<xControlVO.length;i++){ if(xControlVO.charAt(i)=="+"){ result += "%20"; }else if(xControlVO.charAt(i)=="/"){ result += "%2F"; }else if(xControlVO.charAt(i)=="?"){ result += "%3F"; }else if(xControlVO.charAt(i)=="%"){ result += "%25"; }else if(xControlVO.charAt(i)=="#"){ result += "%23"; }else if(xControlVO.charAt(i)=="&"){ result += "%26"; }else{ result += xControlVO.charAt(i); }; } //发送post请求 $.post("/iControl/Control/xControl/saveOrUpdate.action", { xControlVO:xControlVO }, function (data) { alert(data); });
后台:
利用jackson的ObjectMapper实现对象的转化
@Write(type = WriteType.JSON) @Action(value = "saveOrUpdate") public JSONObject saveOrUpdate(@Params(key="xControlVO") String xControlVO){ try { ObjectMapper mapper = new ObjectMapper(); XControlVO vo = mapper.readValue(xControlVO,XControlVO.class);//转成map xControlService.saveORupdate(vo); } catch (Exception e) { e.printStackTrace(); } return null; }
if (typeof(reValue) == "undefined") {
alert("undefined");
}
/**
* 克隆数组
*/
Utils.cloneArray = function(arrayObj) {
var array = new Array();
for (var i = 0, l = arrayObj.length; i < l; i++) {
array.push(Utils.cloneObj(arrayObj[i]));
}
return array;
}
/**
* 克隆对象
*/
Utils.cloneObj = function (obj) {
var objClone = null;
if (obj.constructor == Object) {
objClone = new obj.constructor();
}else {
objClone = new obj.constructor(obj.valueOf());
}
for (var key in obj) {
if (objClone[key] != obj[key]) {
if (typeof (obj[key]) == 'object') {
if (obj[key] instanceof Array) {
objClone[key] = Utils.cloneArray(obj[key]);
}else{
objClone[key] = Utils.cloneObj(obj[key]);
}
}else {
objClone[key] = obj[key];
}
}
}
objClone.toString = obj.toString;
objClone.valueOf = obj.valueOf;
return objClone;
}
$("body").keydown(function (event1) {
try {
var key = event1.which;
if (key == 17) {
//todo
}
}catch(err){}
});
$("body").bind('keyup',function (event) {
try {
var key = event.which;
if (key == 17) {
//todo
}
}catch(err){}
});
解决:
1.1 数据库将该字段格式改为TimeStamp类型
1.2 @Temporal(TemporalType.TIMESTAMP)
@Column(name = "LAST_MODIFIED_TIME", length = 7)
public Date getLastModifiedTime() {
return this.lastModifiedTime;
}
public void setLastModifiedTime(Date lastModifiedTime) {
this.lastModifiedTime = lastModifiedTime;
}
for(String city:citys){
key.concat(city);
}
for(String date:dates){
key.concat(date);
}
key = key.concat(airCompany);
修改为:
StringBuffer sbf = new StringBuffer();// 拼接qte缓存的key
for (String tempCity : citys) {
sbf.append(tempCity);
}
for (String tempDate : dates) {
sbf.append(tempDate);
}
String key = sbf.toString();
key = key.concat(airCompany);
BigDecimal rowCount = (BigDecimal) query.uniqueResult();
return rowCount.intValue();
代替:int size = query.list().size();
return size;
public Long copyAirline(Long airLineId) {
Connection conn=null;
CallableStatement cstmt=null;
try {
JdbcTemplate jdbcTemplate=this.getJdbcTemplate();
conn=jdbcTemplate.getDataSource().getConnection();
String spName="{call sp_copy_policy_airline(?,?)}";
cstmt=conn.prepareCall(spName);
cstmt.setLong(1, airLineId);
cstmt.registerOutParameter(2, oracle.jdbc.OracleTypes.NUMBER);
cstmt.execute();
return cstmt.getLong(2);
} catch (Exception e) {
e.printStackTrace();
log.error(e, e);
}finally{
try {
if(conn!=null){
conn.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
存储SQL,复制存储过程思想,先将需要复制的数据copy到临时表,更新临时表的主键、外键及需要更新的信息,再将临时表数据插入原始表
create or replace
procedure sp_copy_policy_airline(airlineid in number,newairlineid out number) is
v_airlineid number;
Begin
v_airlineid :=SEQ_POLICY_AIRLINES.NEXTVAL;序列的下一个值
insert into IFL_POLICY_AIRLINES_COPY (select G.*,v_airlineid from IFL_POLICY_AIRLINES G where G.POLICY_AIRLINE_ID = airlineid);
commit;
--更新各表外键
update IFL_POLICY_AIR_PARTS_COPY COPYH set policy_airline_id = (select newId from IFL_POLICY_AIRLINES_COPY COPYG where COPYH.policy_airline_id =COPYG.policy_airline_id and rownum <= 1);
--更新各表主键
update IFL_POLICY_AIR_PARTS_COPY set AIR_PART_ID = newId;
--将复制表中的信息插入到原始表
insert into IFL_POLICY_AIRLINES (POLICY_AIRLINE_ID,AIRLINE_CODE,POLICY_ID,TAKEOFF_AIRPORTS,ARRIVE_AIRPORTS,FROM_IS_OJ,TO_IS_OJ,TIME_OFFSET,TCODE,
CLAUSE_ID,CLAUSE_CODE,ALLOW_STOPOVERS,STOPOVERS_TYPE,ALLOW_FLIGHT,NOT_ALLOW_FLIGHT,ALLOW_SHARE_FLIGHT,IS_MARRIAGE,GO_STOPOVERS_TIME,GO_STOPOVERS_FEES,
GO_STOPOVERS_FEES_UNIT,GO_FREE_STOPOVERS_TIME,BACK_STOPOVERS_TIME,BACK_STOPOVERS_FEES,BACK_STOPOVERS_FEES_UNIT,BACK_FREE_STOPOVERS_TIME,GO_ALLOW_TIME,
BACK_ALLOW_TIME,GO_NOT_ALLOW_TIME,BACK_NOT_ALLOW_TIME,TAKEOFF_AREA_TYPE,ARRIVE_AREA_TYPE,START_POINT_CODE,FINISH_POINT_CODE,AIRLINETYPE)
select POLICY_AIRLINE_ID,AIRLINE_CODE,POLICY_ID,TAKEOFF_AIRPORTS,ARRIVE_AIRPORTS,FROM_IS_OJ,TO_IS_OJ,TIME_OFFSET,TCODE,CLAUSE_ID,CLAUSE_CODE,
ALLOW_STOPOVERS,STOPOVERS_TYPE,ALLOW_FLIGHT,NOT_ALLOW_FLIGHT,ALLOW_SHARE_FLIGHT,IS_MARRIAGE,GO_STOPOVERS_TIME,GO_STOPOVERS_FEES,GO_STOPOVERS_FEES_UNIT,
GO_FREE_STOPOVERS_TIME,BACK_STOPOVERS_TIME,BACK_STOPOVERS_FEES,BACK_STOPOVERS_FEES_UNIT,BACK_FREE_STOPOVERS_TIME,GO_ALLOW_TIME,BACK_ALLOW_TIME,
GO_NOT_ALLOW_TIME,BACK_NOT_ALLOW_TIME,TAKEOFF_AREA_TYPE,ARRIVE_AREA_TYPE,START_POINT_CODE,FINISH_POINT_CODE,AIRLINETYPE from IFL_POLICY_AIRLINES_COPY;
update IFL_POLICY_FILES D set LAST_MODIFIED_TIME = SYSDATE() where D.policy_Id = (select G.policy_Id from IFL_POLICY_AIRLINES G where G.policy_airline_id = airlineid);
newairlineid := v_airlineid;
commit;
DELETE FROM IFL_POLICY_AIRLINES_COPY;
commit;
end;
需要替换掉数据库LIMITE_INFORMATION字段字符串中的owPriceSource的值
{"stayTime1":"","stayTime2":"","owPriceSource":"1520","rtPriceSource":"2600"}
update IFL_POLICY_BUNKS set LIMITE_INFORMATION = regexp_replace(LIMITE_INFORMATION,'"owPriceSource"\s*:\s*"([^\\"]|[\\]["]|([\\][\\]))*"','"owPriceSource":"1234"') where POLICY_BUNK_ID in (:POLICY_BUNK_ID_PARAM)
onBlur="if(this.value==''){this.value='审核通过''}"
startAreaCode=startAreaCode.length>20?startAreaCode.substring(0,20)+"...":startAreaCode;
"<td title='"+titleEndAreaCode+"'>到达地:"+endAreaCode+"</td>"