请问function(result)中,result收不到后端传来的数据一般是什么原因? @postmapping和 @responsbody注解返回int类型,但会直接在浏览器上输出数字,不会传到result
<span class="hljs-meta">@PostMapping</span>(<span class="hljs-string">"/goregister"</span>)
<span class="hljs-meta">@ResponseBody</span>
<span class="hljs-keyword">public</span> int <span class="hljs-title function_">goregister</span>(<span class="hljs-params"><span class="hljs-meta">@RequestParam</span>(<span class="hljs-string">"user_name"</span>) <span class="hljs-built_in">String</span> user_name, <span class="hljs-meta">@RequestParam</span>(<span class="hljs-string">"user_password"</span>) <span class="hljs-built_in">String</span> user_password, <span class="hljs-meta">@RequestParam</span>(<span class="hljs-string">"user_sex"</span>) <span class="hljs-built_in">String</span> user_sex, <span class="hljs-meta">@RequestParam</span>(<span class="hljs-string">"user_tel"</span>) <span class="hljs-built_in">String</span> user_tel, <span class="hljs-meta">@RequestParam</span>(<span class="hljs-string">"user_email"</span>) <span class="hljs-built_in">String</span> user_email</span>) {
<span class="hljs-title class_">UserBean</span> userBean=<span class="hljs-keyword">new</span> <span class="hljs-title class_">UserBean</span>();
userBean.<span class="hljs-title function_">setUser_name</span>(user_name);
userBean.<span class="hljs-title function_">setUser_password</span>(user_password);
userBean.<span class="hljs-title function_">setUser_sex</span>(user_sex);
userBean.<span class="hljs-title function_">setUser_tel</span>(user_tel);
userBean.<span class="hljs-title function_">setUser_email</span>(user_email);
userBean.<span class="hljs-title function_">setUser_registration_time</span>(<span class="hljs-string">"NULL"</span>);
userBean.<span class="hljs-title function_">setUser_role</span>(<span class="hljs-string">"普通用户"</span>);
userService.<span class="hljs-title function_">register</span>(userBean);
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
}
$.<span class="hljs-title function_">post</span>(<span class="hljs-string">"/goregister"</span>,{<span class="hljs-attr">user_name</span>:user_name,<span class="hljs-attr">user_password</span>:user_password,<span class="hljs-attr">user_sex</span>:user_sex,<span class="hljs-attr">user_tel</span>:user_tel,<span class="hljs-attr">user_email</span>:user_email},<span class="hljs-keyword">function</span> (<span class="hljs-params">result</span>){
<span class="hljs-keyword">if</span>(result==<span class="hljs-number">1</span>){
<span class="hljs-title function_">alert</span>(<span class="hljs-string">"注册成功!"</span>);
<span class="hljs-variable language_">window</span>.<span class="hljs-property">location</span>.<span class="hljs-property">href</span>=<span class="hljs-string">"/login"</span>;
}