本文收集整理关于springboot怎么返回页面的相关议题,使用内容导航快速到达。
内容导航:
Q1:前台页面怎么调用springboot返回的json字符串
前台页面:
function ajaxPost(){
$.ajax({
data:{"name":$("#name").val(),
"age":$("#age").val(),
"sex":$("input[name=sex]:checked").val()},
type:"Post",
async:false,//加上这个属性就好了
dataType: json,
url:"addStudent.jsp",
error:function(data){
alert(添加失败!);
},
success:function(data){
alert(添加成功!);
window.location.href = http://127.0.0.1/yijitao/list.jsp
}
});
}
Q2:java spring boot 中 controller 与页面 jsp 的交互
表单action的转跳与后端没有关系(如果没有权限拦截的情况下完全无关)。
以spring boot为例,通过controller访问转跳是因为你的controller返回来一个字符串,字符串会自动拼接为jsp或h