<script type="text/javascript" src="/js/require.js" data-main="/js/main" defer async></script>
/**
* Created by PL02053 on 2016/3/10.
*/
require.config({
urlArgs: '_=' + (new Date()).getTime(),
baseUrl: '/js/',
paths: {
'd3': 'd3.v3.min',
'jquery': 'jquery',
'json2': 'json2',
'cookie': 'jquery/Cookies',
'i18n': '../language/i18n'
},
waitSeconds: 0
});
require([
"css!/css/ui/theme.css",
"css!/css/ui/core.css",
"css!/css/ui/button.css",
"css!/css/ui/dialog.css",
"css!/css/ui/menu.css",
"css!/css/ui/tabs.css",
"css!/css/index/tabs.css",
"css!/css/index/index.css",
"css!/css/index/core.css",
"css!/css/zTree/zTreeStyle.css",
"css!/css/index/info.css",
"css!/css/table/ValidateForm.css",
"css!/css/table/SelectDialog.css",
//"css!/css/table/PageToolBar.css",
"css!/css/table/GridTable.css",
"css!/css/index/fileinput.css",
"css!/css/widget/MultiSelect.css",
"css!/js/widget/ExpandTable/css/default.css",
"css!/css/ui/tooltip.css",
'jquery'
], function () {
(function ($) {
require([
/* 'i18n', 'json2', 'cookie', 'jquery/md5', 'd3',
'jquery/mousewheel', 'jquery/resize', 'jquery/ui',
'jquery/ui/dialog',
'jquery/plugins/validate/validate',
'jquery/plugins/WdatePicker/WdatePicker',
'jquery/plugins/zTree/core',
'jquery/plugins/echarts/echarts-all'*/
'i18n', 'json2', 'cookie', 'jquery/md5', 'd3'
], function (i18n) {
//获取设置sessionid
$.ajax({
type: "POST",
url: "/groupParameter/getByIds",
data: JSON.stringify({keys: ['systemLogo']}),
async: false,
dataType: "json",
contentEncoding: "gzip",
contentType: 'application/json',
success: function (data) {
if (data.success) {
if (data.params && data.params.length > 0) {
Cookies.setSessionid(data.params[0]);
}
}
}
});
});
})(jQuery);
});
package controller;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/**
* Created by p00100 on 2017/3/27.
*/
@Controller
@RequestMapping("/groupParameter")
public class xxxController {
@RequestMapping(method = RequestMethod.POST, value = "/getByIds")
@ResponseBody
public ReplyInfo getByIds(@RequestBody JSONObject body, HttpServletResponse response) {
Map<String, Class<?>> typeMap = new HashMap<String, Class<?>>();
typeMap.put("keys", String.class);
ReplyInfo replyInfo = new ReplyInfo();
return replyInfo;
}
}
package controller;
import java.io.Serializable;
import java.util.Arrays;
/**
*
*
* @author Administrator
*/
public class ReplyInfo implements Serializable {
private static final long serialVersionUID = 1L;
private boolean success = true;
private Object data = null;
private String[] params;
public ReplyInfo() {
this.success = true;
}
public ReplyInfo(Object data) {
this.success = false;
this.data = data;
}
public ReplyInfo(Object data, String[] params) {
this.success = false;
this.data = data;
this.params = params;
}
public ReplyInfo(boolean success, Object data) {
this.success = success;
this.data = data;
}
public ReplyInfo(boolean success, Object data, String[] params) {
this.success = success;
this.data = data;
this.params = params;
}
public String[] getParams() {
return params;
}
public void setParams(String[] params) {
this.params = params;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
@Override
public String toString() {
return "ReplyInfo [success=" + success + ", data=" + data + ", params="
+ Arrays.toString(params) + "]";
}
}
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
<dependency>
<groupId>servlet.api</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>json.lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.3</version>
</dependency>
ajax 请求controller
最新推荐文章于 2022-03-31 17:11:14 发布