javaweb遇到的报错问题以及解决方案(持续更新)

时间:2022-07-23
本文章向大家介绍javaweb遇到的报错问题以及解决方案(持续更新),主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

javaweb报错问题以及解决方案

问题(报错信息):Application Server was not connected before run configuration stop, reason: javax.management.InstanceNotFoundException: Catalina:type=Server

解决方案:在使用idea启动tomcat的时候控制台报这个错误,原因是本机的8080端口被占用,在idea里把tomcat的启动端口从新换一个即可

问题(报错信息):org.apache.taglibs.standard.tlv.JstlCoreTLV

根本原因:缺少一个standard-1.1.2.jar

解决办法:在pom.xml中添加standard依赖

 <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.0.6</version>
    </dependency>

问题(报错信息):javax.el.PropertyNotFoundException: The class ‘java.lang.String’ does not have the property ‘id’.

原因:el表达式书写不正确

错误的jsp页面

<c:forEach items="list" var="carlist">
    <tr>
        <td>${carlist.id}</td>
        <td>${carlist.brand}</td>
        <td>${carlist.type}</td>
        <td>¥${carlist.price}</td>
        <td>
            <a href="delete?id=${carlist.id}" class="layui-btn layui-btn-normal">删除</a>
            <a href="alter?id=${carlist.id}" class="layui-btn layui-btn-normal">修改</a>
        </td>
    </tr>
</c:forEach>

正确的jsp页面

<c:forEach items="${list}" var="carlist">
    <tr>
        <td>${carlist.id}</td>
        <td>${carlist.brand}</td>
        <td>${carlist.type}</td>
        <td>¥${carlist.price}</td>
        <td>
            <a href="delete?id=${carlist.id}" class="layui-btn layui-btn-normal">删除</a>
            <a href="alter?id=${carlist.id}" class="layui-btn layui-btn-normal">修改</a>
        </td>
    </tr>
</c:forEach>

正确的el表达式应该是这样:${变量}

报错Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test

在spring-boot项目的ApplicationTests类中测试报这个错误 是因为@SpringBootTest注解没有指定classess属性的值 classess的值就是spring-boot项目的启动类

@SpringBootTest(classes = SsmcarApplication.class)
class SsmcarApplicationTests {

如果不指定还会报空指针异常 junit依赖建议使用与spring-boot结合的依赖

<dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
 </dependency>

报错:com.mysql.cj.exceptions.CJException: Access denied for user ‘root’@‘localhost’ (using password: YES)

springboot项目在配置数据源的时候应该在密码栏加上双引号,特别是以0开头的密码

datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
    url: jdbc:mysql://localhost:3306/ssm?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true
    username: root
    password: "password"