表单提交后报406错误

2019-03-25 13:31|来源: 网路

表单提交后报HTTP Status 406错误:
type:Status report
message:description The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().
我的Controller和jsp是这样写的:
@RequestMapping(value = "acct/save", method = RequestMethod.POST, produces = "text/plain;charset=UTF-8")
public @ResponseBody
String saveAcctount(MemberInfo member, @RequestParam(value = "roleId", required = false) String roleId) {
	if (StringUtils.isEmpty(member.getMemberId())) {
		try {
			memberInfoManager.saveMemberInfo(member, roleId);
			return "新增成功";
		} catch (Exception e) {
			return "新增失败:" + e.getMessage();
		}
	} else {
		try {				
			memberInfoManager.updateMemberInfo(member, roleId);
			return "修改成功";
		} catch (Exception e) {
			return "修改失败:" + e.getMessage();
		}
	}
}

function saveAcct(){
	$('#acctForm').form('submit', {
	    url:acct_save_url + '?roleId=' + $('#acctRole').val(),
	    onSubmit:function(){
	        //$(this).form('validate');
	    },
	    success:function(data){
	    	$.messager.alert('提交结果',data, 'info',function(){
	    		acctLoad();
	     		$('#acctWin').window('close');
	     		$('#acctForm').form('clear');
	     		$('#memberId').remove();
	        	$('#memberName').removeAttr('readonly');
	        	$('#realName').removeAttr('readonly');
	        });
	    }
	});
}

提交后数据还是能保存的,怎么能不报406错误?

相关问答

更多
  • 我破案了! 我正在发送一个format参数与我的获取请求,以告诉服务器发送我的标记而不是HTML。 这是我的Javascript $.get("/annotations/" + annotation_id, {format: 'raw'}, function(data) { }); 然后我在format.js块中寻找这个参数: format.js { if params[:format] == "raw" render :text => @annotation.body.to ...
  • 我不确定你发送的确切标题是什么。 也许你可以尝试添加用户代理(某些注册设备)或更好的只是比较任何浏览器(如chrome)的请求标头与你的应用程序的请求标头。 I am not sure what are the exact headers you are sending. May be you can try adding user-agent(of some registered device) or better just compare the request headers of any brows ...
  • 如果在提交函数中遇到js错误,则错误后的代码将不会执行,这意味着它不会返回false。 您可以在函数开头阻止表单提交,如下所示: $("#myform").submit(function(event) { event.preventDefault(); // it does not matter if there is an error now. console.log(nosuchobject); }); 您仍然应该编写代码,以便它可以正常运行。 if you get a js ...
  • 你想用“json”回答,而不是用“js”回答(这意味着JavaScript)。 jquery_ujs ,为method: :delete添加功能的gem method: :delete ,期望JSON。 def destroy @gcal_user = current_user.gcal_user @gcal_user.delete respond_to do |format| format.html { redirect_to user_root_path } format. ...
  • 我解决了这个问题。 我正在使用config.MapODataServiceRoute(...而不是config.Routes.MapODataServiceRoute...一旦我更改了它,并且使用了正确的语句,一切都开始工作了。 I figured out the problem. I was using config.MapODataServiceRoute(... instead of config.Routes.MapODataServiceRoute... As soon as I changed ...
  • 当您的处理程序方法使用@ResponseBody注释时,Spring通常会生成一个JSON响应主体,将响应content-type为application/json 。 如果您的请求中没有该媒体类型的Accept标头,Spring将认为响应不可接受并返回406错误代码。 您需要在ajax请求中指定Accept标头 headers: { Accept : "application/json" } 使用适当的媒体类型。 I just add this dependency and it's work ...
  • 这是不正确的: http://demo.docusign.net/restapi/v2/login_information? api_password=true&include_account_id_guid=true 它应该在您的GET URL调用中使用HTTPS而不是HTTP: https://demo.docusign.net/restapi/v2/login_information? api_password=true&include_account_id_guid=true 你的错误实际上 ...
  • 你不必添加:method =>:delete到你的销毁链接? 您也可能不希望使用new_category_idea_vote_path来生成destroy链接,而只是使用category_idea_vote_path 像那样: content_tag( :p, link_to("+#{i}", category_idea_vote_path(category, idea, :weight => i), :remote => true, :method => :delete ), :class => "val ...
  • 删除任何使用Angular发送的标头,例如 $httpProvider.defaults.headers.common['Accept'] = 'application/json'; 似乎IIS无法处理通过Javascript发送的标头,就像其他“普通”Web服务器一样(参见Nginx或Apache)。 Delete any header sent with Angular, like $httpProvider.defaults.headers.common['Accept'] = 'applica ...
  • incident对象不是正确序列化的JSON字符串。 您需要调用JSON.stringify(this.incident)以获取等效的JSON字符串,并指定application/json HTTP标头。 $.ajax({ url: 'http://example.com:9200/incidents/incidents', type: 'POST', data: JSON.stringify(this.incident), ...