该问题再返回Json数据时候是由于没有导入Jackson的架包导致的.

HTTP Status 406 – Not Acceptable
Type Status Report
Description The target resource does not have a current representation that would be acceptable to the
user agent, according to the proactive negotiation header fields received in the request, and the
server is unwilling to supply a default representation.
Apache Tomcat/8.5.33

我们需要在pox.xml文件中添加依赖即可(jackson-core,jackson-annotations,jackson-databind)。

HTTP Status 500 – Internal Server Error
Type Exception Report
Message Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/ComboPooledDataSource
Description The server encountered an unexpected condition that prevented it from fulfilling the request.

该问题是使用c3p0连接池时发生的错误,缺少c3p0的jar包,在配置c3p0时候共需要导入两个架包(c3p0-0.9.2,mchange-commons-java-0.2.3.4)

信息 [MLog-Init-Reporter] com.mchange.v2.log.MLog. MLog clients using java 1.4+ standard logging.

该问题导致的原因未将jar导入到我们的项目中

springmvc访问接口404
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists

该问题存在的原因如下: pox.xml中没有添加适合的依赖,扫描器中没有扫描到控制器或者没有扫描控制器。

org.springframework.web.servlet.FrameworkServlet.initServletBean Initializing Servlet 'spring'......忘记截图全内容了,淦

该问题出现的原因是因为pom.xml中没有导入相关的spring框架依赖.

我们只需要在pom.xml中加入这几行,再次运行就基本上ok了。

<dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jdbc</artifactId>
          <version>4.1.6.RELEASE</version>
      </dependency>
       <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>
     <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context-support</artifactId>
          <version>4.1.6.RELEASE</version>
      </dependency>

这里再提醒一点在导入所有依赖后进入File->Project Structure->Artifacts中再更新一下库文件,否则可能会出现406 400 500等情况,还有在添加依赖同时要将依赖放在<dependencies>标签之中,不然的话够搞半天咯.

本人在SpringMvc框架搭建中遇到的主要问题就是这些,后期还会进行更新,这里附上一份文件pom.txtSpringMvc.txt

最后修改:2021 年 04 月 24 日
如果觉得我的文章对你有用,请随意赞赏