关于springBoot+thymeleaf环境下返回HTML的问题(已解决)
2019-05-18 03:24
941 查看
关于springBoot+thymeleaf环境下返回页面的问题(已解决)
2019年5月18日03:02:26
第一次用这个框架写系统,17号下午因为获取css.js的问题已经耗费了我大半天的时间,晚上又碰到返回页面的时候一直给我返回字符串。。看了很多回答也没有解决。
先看我的错误
前端部分,使用ajax发送请求
function test(){ $.ajax({ url:"/user/index", //相当于form里的action="book_list" type:"post", data:{ uname:$("#uname").val(), upassword:$("#upassword").val() }, success:function(result){ alert(result) } }); }
后端部分 (idea springboot thymeleaf)
返回结果
没有跳转页面,将字符串返回了出来。。尝试了CSDN上很多回答
1、@controller
2、pom.xml添加thymeleaf依赖
3、修改配置文件
以上统统试过对我没用
我甚至想不用这个来跳转页面了,在前端用js来跳转
后来…
我把提交请求的方式改成了 form表单来提交
<form id="fm" action="/user/index2"> <input class="but" id="uname" type="text" name="uname" placeholder="账 号"> <input class="but" id="upassword" type="password" name="upassword" placeholder="密 码"> <input class="but" id="log" type="submit" value="立即登录"> </form>
居然就可以跳转成功了
无论返回的是String 还是modelAndView类型
哎。。。。。花了我一晚上的时间现在是2019年5月18日03:22:53
希望对其他人有用。
相关文章推荐
- 加入spring-boot后导致maven的profile多环境配置失效的问题解决
- Spring boot 关于在Maven下的pom.xml添加对redis的支持报错解决问题
- springboot+jersay环境下解决long类型到前台精度丢失的问题
- 关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration问题解决方案
- [小技巧]关于spring boot 整合mybatis-plus: value为null时不返回的问题。
- 关于SpringBoot启动类报错的问题解决
- 关于Spring4.1+版本的后台返回json问题说明及解决办法
- 关于写u_boot时环境变量存储问题解决办法
- Spring boot项目maven的profile多环境配置不自动替换变量的问题解决
- Springboot使用FastJson后,接口返回中文乱码的问题解决。
- 关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration问题解决方案
- 关于spring boot无法自动注入bean问题解决方案
- 关于spring boot整合druid连接池在程序关闭后连接不释放问题解决
- spring boot+thymeleaf出现Error resolving template之类问题的解决
- SpringBoot 中关于html中js,css 自动加上Controller层前缀,报404问题
- 关于SpringBoot无法加载前端界面以及加载成功之后页面无法加载Css/Js等问题的解决。
- spring boot新手教程之使用FastJson解析JSON数据以及解决返回中文乱码问题
- 雷丰阳Springboot视频培训教程问题解决记录之五——Bootstrap4、DatePicker和Thymeleaf
- 关于解决spring 只能跳转到.jsp 不能跳转到.html的问题
- Spring boot 项目 maven的profile多环境配置 不自动替换变量的问题解决