一,html脚本
<script type="text/javascript">
$(function() {
$(".btn-submit").click(function() {
var url = ‘${rc.contextPath}/wxFfanApply.htm?method=save‘;
var param = $("#submitForm").serialize();
$.ajax({
url: url,
type: ‘POST‘,
dataType: ‘json‘,
data: param,
async: false,
success: function(data){
if ("000" == data.code) {
alert("保存成功");
var url = ‘${rc.contextPath}/wxFfanApply.htm?method=preToMain‘;
document.getElementById(‘submitForm‘).action = url;
document.getElementById(‘submitForm‘).submit();
} else {
alert("保存出现异常,请重试");
}
}
});
});
});
</script>
<body>
<div class="page-upload">
<form id="submitForm" action="" method="post">
<input type="hidden" name="wxOpenId" value="${wxOpenId}"/>
<input type="hidden" name="applyId" value="${applyId}"/>
<input type="hidden" name="wxModuleType" value="${wxModuleType}"/>
<input type="hidden" name="fssId" id="fssId" />
<input type="hidden" name="originalFilename" id="originalFilename" />
<input type="hidden" name="imageType" id="imageType" />
<input type="hidden" name="companyType" id="companyType" />
<input type="button" class="btn-upload bg-business-license" name="yushow" id="yushow" value="点击上传营业执照" onclick="uploadBtn();">
<input type="file" name="upload" style="display:none;" onchange="previewImg(this);" id="upload" accept="image/*"/>
<ul class="info-list">
<li class="info-list-li">
<label class="lable-with-bg">注册号/信用代码</label>
<div class="li-right">
<input type="text" class="input-before-btn" placeholder="扫码可自动填充" name="businessRegno" value="${orderParam.businessRegno!}"/>
<button class="btn-scan"></button>
</div>
</li>
<li class="info-list-li">
<label>企业名称</label>
<input type="text" placeholder="请填写营业执照上的名称" name="merchantName" value="${orderParam.merchantName!}"/>
</li>
<li class="info-list-li">
<label>企业类型</label>
<div id="trigger1" >请选择</div>
</li>
<li class="info-list-li">
<label>法人/负责人名称</label>
<input type="text" placeholder="请填执照上负责人名称" name="legalName" value="${orderParam.legalName!}"/>
</li>
<li class="info-list-li">
<label>经营范围</label>
<input type="text" placeholder="请填执照上的经营范围" name="businessScope" value="${orderParam.businessScope!}"/>
</li>
<li class="info-list-li">
<label>注册地址</label>
<input type=‘text‘ id=‘sel_city‘ name="selCity"placeholder=‘请选择‘ />
</li>
<li class="info-list-li">
<label>详细地址</label>
<input type="text" placeholder="与营业执照地址一致" name="address" value="${orderParam.address!}"/>
</li>
<li class="info-list-li">
<label>有效期始</label>
<input id="startDate" name="startDate" class="select" placeholder="请选择开始日期"/>
</li>
<li class="info-list-li">
<label>有效期止</label>
<input id="endDate" name="endDate" class="select" placeholder="请选择开始日期"/>
</li>
<li class="info-list-li">
<label>三证合一</label>
<div class="li-right">
<div class="slide-block">
<div class="slide-block-ball"></div>
<input type="hidden" id="isUniformSocialCredit" name="isUniformSocialCredit" value=""/>
</div>
</div>
</li>
</ul>
<div class="btn-wrapper">
<button class="btn-submit">保存</button>
</div>
</form>
</div>
二,java代码
2.1,代码一
public void save(HttpServletRequest request, HttpServletResponse response) {
logger.info("save info begin...");
Map<String, Object> result = new HashMap<String, Object>();
try {
String wxOpenId = request.getParameter("wxOpenId");
String applyId = request.getParameter("applyId");
String wxModuleType = request.getParameter("wxModuleType");
if (StringUtil.isEmpty(wxOpenId) || StringUtil.isEmpty(applyId)
|| StringUtil.isEmpty(wxModuleType)) {
result.put("code", "001");
result.put("desc", "必填参数为空");
super.toJson(result, response);
return;
}
// 获取request里的所有参数,作为orderParam
String paramJson = packageOrderParam(request);
}
2.2,代码二
protected String packageOrderParam(HttpServletRequest request)
throws Exception {
Map<String, Object> paramMap = getParameterMap(request);
String selCity = request.getParameter("selCity");
if(StringUtil.isNotEmpty(selCity)){
String [] arr = selCity.split("\\s+");
String province=null;
String city=null;
String country=null;
for (int i = 0; i < arr.length; i++) {
switch (i) {
case 0:
province = arr[i];
break;
case 1:
city = arr[i];
break;
case 2:
country= arr[i];
break;
default:
break;
}
}
paramMap.put("province", province);
paramMap.put("city", city);
paramMap.put("country", country);
}
return JsonUtils.map2Json(paramMap);
}
2.3,代码三
@SuppressWarnings("unchecked")
public Map<String, Object> getParameterMap(HttpServletRequest request) {
Map<String, Object> resultMap = new HashMap<String, Object>();
Map<String, String[]> map = request.getParameterMap();
Set<Map.Entry<String, String[]>> set = map.entrySet();
Iterator<Map.Entry<String, String[]>> it = set.iterator();
while (it.hasNext()) {
Map.Entry<String, String[]> entry = (Map.Entry<String, String[]>) it.next();
for (String v : (String[]) entry.getValue()) {
resultMap.put(entry.getKey(), v);
}
}
return resultMap;
}