1、springboot 报错Field XXX required a bean of type XXX that could not be found.
Description:
Field menuService in com.goodidea.sso.controller.MenuController required a bean of type 'com.goodidea.sso.service.MenuService' that could not be found.
Action:
Consider defining a bean of type 'com.goodidea.sso.service.MenuService' in your configuration.
在代码service上缺少相应的注解,像这样补充完注解即可
@Service
public class MenuServiceImpl implements MenuService
错误提示:com.czw.spring.boot.blog.controller.UserspaceController required a bean of ……
错误原因:BlogServiceImpl没有加@Service注解
2、$(this).attr("blogUrl") 代表含义
$(this).attr(key); 获取节点属性名的值,相当于getAttribute(key)方法
$(this).attr(key, value); 设置节点属性的值,相当于setAttribute(key,value)方法
eg:<div id="w_1" class="widget" diywidgetid="${template.diyWidgetId}"></div>
var diywidgetid = $('#w_1').attr('diywidgetid'); //获取节点属性的值
$(this).val();获取某个元素节点的value值,相当于$(this).attr(“value”);
$(this).val(value);设置某个元素节点的value值,相当于$(this).attr(“value”,value);
eg:<input id="i_eg" value="1" type="text"></input>
var i_eg=$('#i_eg').val(); // 获取元素节点的value 值
3、页面加载错误:controller中的链接前面多了个“/”,这个问题,经常出现在controller中return方法,从地址到HTML地址时。
org.thymeleaf.exceptions.TemplateInputException:
An error happened during template parsing (template: "class path resource [templates//userspace/blog.html]")
4、这个错误应该是变量名不一致,或者写错了,或者是私有的,不能直接访问,要用get方法访问。
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "blogModel.reading" (template: "/userspace/blog" - line 32, col 68)
5、blogedit.js提交时去不到id的值,在ajax里面就是undefined
错误写法:如果将一个空变量,强制转化成数字,则为0,返回后台的blogId=0,但是查询不到该ID的博客,因此报错。
"id":Number($('#iidd').val()),
正确写法
"id":$('#iidd').val(),