问题一: 路径找不到,在springboot项目中,配置css,js,img都是在static下面配置,这是springboot定好的,如果自己resource目录下没有static文件夹,就创建一个。
然后,编写路径时,直接从根目录开始写就行,“/v1/js........”中的第一个斜线就是代表根目录,v1是下面的一个文件夹,可以表示版本。
<script src="/v1/js/index.js"></script>
如果自己路径写的对,但是仍然加载不出来,可以去清除缓冲,如图中所示,在maven中找到根目录进行清除。然后在此启动
如果此时还是不行的话,就要清除浏览器的缓存 ,把下图的disable cache 对钩勾选上
There is already 'indexController' bean method net.yierde.web.controller.IndexController#notice() mapped.
这个是在你的controller中 有重复的 路径名
解决方案:更改路径名称
问题三:当从数据库中查数据时,数据库中没有下划线的能查出来,有下划线的不能查出来,
解决方法:
应该是 ,查询时,mapper.xml中的返回类型是实体类,而不是resultmap,因为数据库字段与代码中的实体类没有一一对应。所以要把在mapper中的返回的实体类类型,变成resultMap的id去一一映射起来
问题四:"Ambiguous handler methods mapped for '/users/ceshi123': {public net.yierde.common.core.web.domain.AjaxResult net.yierde.web.controller.UserController.getInfo(java.lang.String), public net.yierde.common.core.web.domain.AjaxResult net.yierde.web.controller.UserController.selectUserByNameToPhone(java.lang.String)}",
解决方法:
这是因为controller类中有一个相似的方法。
EG: 这种情况就会 出上面的问题
/**
* @return ajax
*/
@GetMapping("/getPhone/")
public AjaxResult selectUserByNameToPhone(@PathVariable("userName")String userName){
//
return AjaxResult.success(user1);
}
/**
*/
@GetMapping("/list")
public TableDataInfo list(User user)
{
List<User> list = userService.selectUserList(user);
return getDataTable(list);
}
问题五:接受参数问题
在使用,检测数字类型参数方法时,接收的id大于当时的最大值,就会给空
CommonUtil.getParamInt(param.get("id"),0,10000,null);
以后一定要用debug去找错误,最好尽可能的不去使用输出语句,因为有一些问题找不到,会有默认值输出,出来
问题6:to {POST /supplier}: There is already 'invoice Supplier Controller' bean method net.yierde.banking.asset.controller.InvoiceSupplierController#add(InvoiceSupplier) mapped.
这个是两个controller类中的RequestMapping(“路径”),“路径”重复了
知识1:
伪删除,使用伪删除,就是把数据库中的is_delete(0假,1真)字段改为1(已删除),url是delete,controller类删除方法上面的 mapping是DeleteMapping。
Request method 'DELETE' not supported", 这种错误
localhost:8080/user/7,8,9
知识:SpringBoot打印sql语句
方法一:这里使用的 application.properties。如果是yml 的是就是点换成冒号
logging.level.com.zzy.demos.mapper:DEBUG
方式二:
#Log4g打印SqL语句
mybatis
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl