0401日志

本文档详细解析了SpringBoot应用中常见的依赖注入错误及其解决办法,并介绍了jQuery中属性获取与设置的方法,同时分享了页面加载配置及调试技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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(), 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值