Tag: spring mvc

Spring MVC + Jquery Ajax显示406错误?

我已经搜索了很多,无法找到解决方案。类似的线程也在我们的堆栈溢出。但没有用。所以我创建了一个新的线程。 我的JSP是, Spring_JsonTest Example Enter your name : Your Education : 我的Jquery是, function doAjaxPost() { // get the form values var name = $(‘#name’).val(); var education = $(‘#education’).val(); $.ajax({ type: “POST”, url: contexPath + “/AddUser.html”, data: “name=” + name + “&education=” + education, success: function(response){ // we have the response if(response.status == “SUCCESS”){ userInfo = […]

JqG​​rid无法显示数据

我试图从弹簧控制器显示JqGrid中的数据。 这是来自我的spring控制器的JSON响应{“rows”:[{“firstName”:”sharma”,”lastName”:”sharma”,”id”:2}],”page”:”1″,”records”:”1″,”total”:”1″} 这是我的jsp文件: $(“#grid”).jqGrid({ url:’/url’, colModel:[ {name:’id’, label: ‘ID’, formatter:’integer’, width: 40}, {name:’firstName’, label: ‘First name’, width: 300}, {name:’lastName’, label: ‘Last Name’, width: 200} ], caption: “ReportingEmployees”, pager : ‘#pager’, height: ‘auto’ }).navGrid(‘#pager’, {edit:false,add:false,del:false, search: false}); 我花了几个小时来弄清楚出了什么问题,JSON看起来也很有效。 任何帮助深表感谢。

无法使用ajax将Jpartery中的Multipart文件发送到spring控制器

我试图将Multipart文件从jquery发送到spring控制器。 以下是我得到的错误 WARN : org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver – Handler execution resulted in exception: org.springframework.validation.BeanPropertyBindingResult: 1 errors Field error in object ‘addressDTO’ on field ‘addrDocImage’: rejected value [590768c44b1291493657796.png]; codes [typeMismatch.addressDTO.addrDocImage,typeMismatch.addrDocImage,typeMismatch.org.springframework.web.multipart.MultipartFile,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [addressDTO.addrDocImage,addrDocImage]; arguments []; default message [addrDocImage]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘org.springframework.web.multipart.MultipartFile’ for property ‘addrDocImage’; nested exception […]

jQuery-File-Upload和Spring MVC IE9不起作用

我使用jQuery-File-Upload和Spring MVC之类的服务器部分。 我尝试了这个例子 ,它在IE 9浏览器中不起作用。 它告诉我:“你想保存或打开物体” 客户端就像在示例中: jQuery File Upload Example $(function () { $(‘#fileupload’).fileupload({ dataType: ‘json’, done: function (e, data) { $.each(data.result.files, function (index, file) { $(”).text(file.name).appendTo(document.body); }); } }); }); 服务器是: @RequestMapping(value = “fileUpload/{id}”, method = RequestMethod.POST) @ResponseBody public FileUploadResultDTO upload(MultipartFile file, @PathVariable Long id, Locale locale, HttpServletRequest request) { FileUploadResultDTO resultDTO = […]

如何使用jQuery.i18n.properties.js + Spring 3 mvc加载i18n属性文件

我在Spring 3中配置了本地化和内部化mvc.I将属性文件放在资源文件夹中。它工作正常。现在我想使用Javascript内化来根据语言提供正确的警报消息。 我的项目结构在下面给出了属性文件 Project | | src resource |_message.properties |_message_en.properties |_message_es.properties 我想使用jQuery internalization.Now我想使用jQuery访问这些属性文件。我在javascript中编写了以下代码来加载我的属性文件 jQuery.i18n.properties({ name:’message’, path:’resources/’, mode:’both’, language:’en’ }); **But I am getting Http 404 Error during loading of the page.** **GET http://SERVER IP:PORT/viuw/resources/message.properties?_=1373877147985 404 (Not Found)** How to load Property files using jQuery.i18n.property.js? my configuration is web.xml file configuration is spring org.springframework.web.servlet.DispatcherServlet 1 spring […]

415不支持的媒体类型,用于在ajax调用Spring mvc中发送json对象

我从jj调用发送json对象到spring mvc控制器。 这是我发给控制器的json对象。 [{“id”:”7″,”priority”:”8″,”startTime”:”2015-09-23 01:01:00.0″}] 我的ajax电话 $.ajax({ url : ‘save.web’, datatype:’json’, type: “post”, data: “data=”+JSON.stringify(jsonArray), success:function(data){ } 我的控制器 RequestMapping(value = “save.web”, method = RequestMethod.POST) public String save( HttpServletRequest request, HttpServletResponse response,@RequestBody Map inputParameter, @RequestParam(“data”) String ja) { System.out.println(“————–Entered Save———–“); return “menu” } 我尝试使用@requestBody注释而不是@requestParam。 我尝试设置标题并在RequestMapping中使用Consumes仍然我得到POST http:// localhost:8089 / campaignManager / save.web 415(不支持的媒体类型)错误。 请让我知道解决方案。 我尝试了很多

登录Ajax成员时如何修复会话错误? – Spring MVC2

MemberService.java: public HashMap login(String id,String pw) { HashMap result = memberDao.selectOne(id); if(result != null) // 존재하는 값이 있으면 { String opwd = (String) result.get(“pw”); // opwd = 존재하는값의 pw값을 가져온 값 if(opwd.equals(pw)) { return result; // true면 존재하는값을 반환 } else { return null; //return null; // 아니면 값을 반환하지 않음. } } else // […]

在ajax调用中返回ModelAndView之间的区别

为什么当我在调用ajax中返回一个ModelAndView时它会工作并正常显示jsp页面但是当我将它返回到具有其他对象的地图时它不起作用。 第一个工作案例: @RequestMapping(value=”/searchlostcard”) public @ResponseBody ModelAndView searchlostcard() { […] return new ModelAndView(“search/results”,”cardlist”, listlostcard); ; } 我的ajax电话 […] success : function(responce) { $(‘#page_grid’).html(responce); } 第二种情况不起作用: @RequestMapping(value=”/searchlostcard”) public @ResponseBody Map searchlostcard() { […] ModelAndView MaV = new ModelAndView(“search/results”,”cardlist”, listlostcard); Map modelino = new HashMap(); modelino.put(“taille”, listlostcard.size()); modelino.put(“vue”, MaV); return modelino ; } 我的ajax电话 […] success : function(responce) […]

spring mvc jquery ajax响应为json编码问题

Recenlty我在服务器的JSON响应中遇到波兰字符的大问题。 我有简单的Ajax请求: jQuery.ajax( “/GetSimpleRuleList”, { type:”GET”, responseType:”application/json;charset=utf-8″, contentType:”application/json;charset=utf-8″, cache:false } ).done( function ( data ) { console.log( data ); //nevermind here } ); 服务器端的适当控制器: @RequestMapping(value = “/GetSimpleRuleList”, method = RequestMethod.GET) public @ResponseBody String getRuleList( ServletResponse response ) { //magically getting my list here response.setCharacterEncoding( “UTF-8” ); return //Using JACKSON ObjectWriter here } 现在我100%确定服务器端和数据库中的encoidng从中获取数据是好的,没问题。 但是当谈到从服务器读取响应时,它是: ??? […]

Spring MVC @RequestBody不使用jquery ajax?

这是我的ajax请求 var dataModel = {name1:”value1″, name2:”value2″}; $.ajax({ url: “/testURL”, type: “POST”, async: false, contentType: “application/json”, data: dataModel, success: function(response) { } }) 这是我在spring xml中的相关代码片段 这是我的控制器映射 @RequestMapping(value = “/testURL”, method = { RequestMethod.POST }) public String add(HttpServletRequest request, @RequestBody CustomObject customObject) throws Exception {} 但我的要求甚至没有达到控制器。 一旦我删除@RequestBody CustomObject customObject就可以了。 但我想用@RequestBody将json请求映射到CustomObject,这是没有发生的。 不知道我在这里缺少什么? 实际上,当我检查request.getParameterMap()它显示为空,但是一旦我删除了contentType: “application/json”我看到参数map被填充,但仍然会得到以下错误 `The server refused this […]