mvc字符串数组怎么获取
前端展示数据是从字典表里面取值
页面的ID name是动态取出展示 表单提交怎么获取
2 回复
<%
layout("/layouts/private.html"){
%>
<header class="header navbar bg-white shadow">
<div class="btn-group tool-button">
<a class="btn btn-primary navbar-btn" href="${base}/private/app/product/indexDetail/${prodId}" data-pjax><i class="ti-angle-left"></i> 返回</a>
</div>
</header>
<div class="content-wrap">
<div class="wrapper" style="min-height:500px;height: 100%;">
<form id="addForm_detail" role="form" class="form-horizontal parsley-form" data-parsley-validate
action="${base}/private/app/inventory/addDo" method="post">
<div class="col-lg-12">
<input type="hidden" id="prodId" name="prodId" value="${prodId}">
<%
if(!isEmpty(specs)){
for(spec in specs){
%>
<div class="form-group has-feedback">
<label for="${spec.code}Id" class="col-sm-2 control-label">${spec.name}</label>
<div class="col-sm-8">
<div class="input-group">
<input id="${spec.code}Id" type="text" class="form-control" data-parsley-required="true" placeholder="请选择${spec.name}" disabled
value="<%if(!isEmpty(spec)){%>${spec.name}<%}%>" />
<span class="input-group-btn">
<button type="button" class="btn btn-primary" data-toggle="modal"
data-target="#dialogSelect_${spec.code}"><i class="ti-plus"></i>选择
</button>
</span>
</div>
<input type="hidden" name="${spec.code}Id" value="<%if(!isEmpty(spec)){%>${spec.id}<%}%>">
<input type="hidden" name="${spec.code}" value="<%if(!isEmpty(spec)){%>${spec.name}<%}%>">
</div>
</div>
<%}}%>
<div class="form-group">
<label for="prodNum" class="col-sm-2 control-label">产品数量</label>
<div class="col-sm-8">
<input type="text" id="prodNum" class="form-control" name="prodNum" data-parsley-required="true" placeholder="产品数量">
</div>
</div>
<div class="form-group">
<label for="prodUrls" class="col-sm-2 control-label">产品颜色图</label>
<div class="col-sm-8">
<div id="queue"></div>
<div>
<input id="file_upload" name="file_upload" type="file" multiple="false">
</div>
<div id="img" style="padding: 5px;">
</div>
<input type="hidden" id="prodUrls" name="prodUrls" />
</div>
</div>
<div class="col-lg-3"></div>
<div class="col-lg-6">
<div class="form-group text-center">
<label></label>
<div>
<button class="btn btn-primary btn-block btn-lg btn-parsley"
data-loading-text="正在提交...">提 交</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<div id="dialogSelect_size" class="modal fade bs-modal-sm" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">选择</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-xs-12">
<div id="jsTree_size" class="demo"></div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
<button type="button" class="btn btn-primary" onclick="select('size')">确认选择</button>
</div>
</div>
</div>
</div>
<div id="dialogSelect_color" class="modal fade bs-modal-sm" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">选择</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-xs-12">
<div id="jsTree_color" class="demo"></div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
<button type="button" class="btn btn-primary" onclick="select('color')">确认选择</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function clearFile() {
$("#img").html("");
$("#queue").html("");
$("#prodUrls").val("");
}
function initTreeView(id,path) {
var treeUrl = "${base}/private/sys/dict/treeSpec?";
var code = ""
$("#jsTree_"+id).jstree({
plugins: ["wholerow", "json_data"],
core: {
data: {
dataType: "json",
url: function (node) {
return node.id === "#" ? treeUrl + "code=" + id : treeUrl + "pid=" + node.id
}
},
multiple: false
}
}).on("dblclick.jstree", function (node) {
select(id);
});
}
//选择父菜单
function select(id) {
var tree = $.jstree.reference("#jsTree_"+id);
var node = tree.get_selected(true);
$("#addForm_detail #"+id+"Id").val(node[0].text);
$("#addForm_detail input[name='"+id+"Id']").val(node[0].id);
$("#addForm_detail input[name='"+id+"']").val(node[0].text);
$("#dialogSelect_"+id).modal("hide");
}
var uploads;
$(document).ready(function () {
initTreeView("size","size");
initTreeView("color","color");
$('#file_upload').uploadifive({
'auto': true,
'multi': false,
'width': '100%',
'height': '35',
'buttonText': '请选择图片',
'fileType': 'image/*',
'fileSizeLimit': 1024,
'queueSizeLimit': 1,
'formData': {},
'queueID': 'queue',
'uploadScript': '${base}/open/file/upload/image',
'onUploadComplete': function (file, data) {
data = JSON.parse(data);
if (data.code == 0) {
Toast.success(data.msg);
$("#img").html("<img src='" + data.data + "' style='width:150px;height:95px;'>");
$("#prodUrls").val(data.data);
} else {
clearFile();
Toast.error(data.msg);
}
},
'onDrop': function (file, fileDropCount) {
clearFile();
},
'onClearQueue': function (queue) {
clearFile();
},
'onCancel': function () {
clearFile();
}
});
$('#addForm_detail').ajaxForm({
dataType: 'json',
beforeSubmit: function (arr, form, options) {
var prodUrls = $("#prodUrls").val();
if(prodUrls != ""){
sublime.showLoadingbar($(".main-content"));
}else{
Toast.error("请上传图图片");
return false;
}
},
success: function (data, statusText, xhr, form) {
if (data.code == 0) {
Toast.success(data.msg);
form.resetForm();
clearFile();
} else {
Toast.error(data.msg);
}
sublime.closeLoadingbar($(".main-content"));
}
});
});
</script>
<%}%>
@At("/add/?")
@Ok("beetl:/private/app/product/add_detail_test.html")
@RequiresAuthentication
public void add(@Param("prodId") String prodId, HttpServletRequest req) {
Sql sql = Sqls.create("select s.specId from app_prod_cate_spec as s join app_product as p on(s.cateId=p.cateId) where p.id=@prodId");
sql.setParam("prodId", prodId);
List<Record> rs = specService.list(sql);
int len = rs.size();
if(len > 0){
String[] ids = new String[len];
for(int i = 0; i < len; i++){
ids[i] = rs.get(i).getString("specId");
}
List<App_prodSpec> specs = specService.query(Cnd.where("id", "in", ids));
req.setAttribute("specs", specs);
}
req.setAttribute("prodId", prodId);
}
没法指定NAME
添加回复
请先登陆