1.页面传递来的参数的默认值。返回的参数也是转化为json形式
@RequestMapping("/item/cat/list")
@ResponseBody public List<EasyUITreeNode> list(@RequestParam(value="id", defaultValue = "0") Long parentId) { List<EasyUITreeNode> itemCatList = itemCatService.getItemCatList(parentId); return itemCatList; }2.
@RequestMapping("/{page}")
public String showIndex(@PathVariable String page){ return page; }3.properties文件中定义的常量
@Value("${IMAGE_SERVER_URL}")
private String IMAGE_SERVER_URL;4.
//返回一个json,json中有一个error,url;error,message
@RequestMapping(value="/pic/upload",produces=MediaType.TEXT_PLAIN_VALUE+";charset=utf-8") @ResponseBody public String picUpLoad(MultipartFile uploadFile){ try { System.out.println("aaa"); //接收页面上传的文件 byte[] content = uploadFile.getBytes(); //去文件的扩展名 String filename = uploadFile.getOriginalFilename(); String ext = filename.substring(filename.lastIndexOf(".")+1); //把文件内容上传到图片服务器 FastDFSClient fastDFSClient = new FastDFSClient("classpath:resource/fast_dfs.conf"); //从配置文件中取图片服务器的url String url = fastDFSClient.uploadFile(content, ext); //设置创建返回结果对象 Map map = new HashMap(); map.put("error", 0); map.put("url", IMAGE_SERVER_URL+url); //返回结果 return JsonUtils.objectToJson(map); } catch (Exception e) { Map map = new HashMap(); map.put("error", 1); map.put("message", "图片上传失败"); return JsonUtils.objectToJson(map); } }5.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加业务受理单</title> <!-- 导入jquery核心类库 --> <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script> <!-- 导入easyui类库 --> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/themes/icon.css"> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/ext/portal.css"> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/default.css"> <script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui/ext/jquery.portal.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui/ext/jquery.cookie.js"></script> <script src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $("body").css({visibility:"visible"}); // 对save按钮条件 点击事件 $('#save').click(function(){ // 对form 进行校验 if($('#noticebillForm').form('validate')){ $('#noticebillForm').submit(); } }); }); </script> </head> <body class="easyui-layout" style="visibility:hidden;"> <div region="north" style="height:31px;overflow:hidden;" split="false" border="false"> <div class="datagrid-toolbar"> <a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true">新单</a> <a id="edit" icon="icon-edit" href="${pageContext.request.contextPath }/page_qupai_noticebill.action" class="easyui-linkbutton" plain="true">工单操作</a> </div> </div> <div region="center" style="overflow:auto;padding:5px;" border="false"> <form id="noticebillForm" action="${pageContext.request.contextPath }/noticebillAction_save.action" method="post"> <table class="table-edit" width="95%" align="center"> <tr class="title"> <td colspan="4">客户信息</td> </tr> <tr> <td>来电号码:</td> <script> $(function(){ //为手机号输入框绑定离焦事件 $("input[name=telephone]").blur(function(){ //发送ajax请求,访问Action,在Action中调用crm项目根据手机号查询客户信息,在Action中将查询出的客户信息 //序列化为json数据返回页面 var telephone = this.value; var url = "${pageContext.request.contextPath}/noticebillAction_findCustomerByPhone.action"; $.post(url,{"phone":telephone},function(data){ if(data != null){ //将客户的信息显示到当前页面上 $("input[name=customerId]").val(data.id); $("input[name=customerName]").val(data.name); $("input[name=delegater]").val(data.name); $("input[name=pickaddress]").val(data.address); }else{ $("input[name=customerId]").val(""); $("input[name=customerName]").val(""); $("input[name=delegater]").val(""); $("input[name=pickaddress]").val(""); } }); }); }); </script> <td><input type="text" class="easyui-validatebox" name="telephone" required="true" /></td> <td>客户编号:</td> <td><input type="text" class="easyui-validatebox" name="customerId" required="true" /></td> </tr> <tr> <td>客户姓名:</td> <td><input type="text" class="easyui-validatebox" name="customerName" required="true" /></td> <td>联系人:</td> <td><input type="text" class="easyui-validatebox" name="delegater" required="true" /></td> </tr> <tr class="title"> <td colspan="4">货物信息</td> </tr> <tr> <td>品名:</td> <td><input type="text" class="easyui-validatebox" name="product" /></td> <td>件数:</td> <td><input type="text" class="easyui-numberbox" name="num" /></td> </tr> <tr> <td>重量:</td> <td><input type="text" class="easyui-numberbox" name="weight" /></td> <td>体积:</td> <td><input type="text" class="easyui-validatebox" name="volume" /></td> </tr> <tr> <td>取件地址</td> <td colspan="3"><input type="text" class="easyui-validatebox" name="pickaddress" required="true" size="144"/></td> </tr> <tr> <td>到达城市:</td> <td><input type="text" class="easyui-validatebox" name="arrivecity" /></td> <td>预约取件时间:</td> <td><input type="text" class="easyui-datebox" name="pickdate" data-options="editable:false" /></td> </tr> <tr> <td>备注:</td> <td colspan="3"><textarea rows="5" cols="80" type="text" class="easyui-validatebox" name="remark" ></textarea></td> </tr> </table> </form> </div> </body> </html>