首次用SSM框架时,localhost:8080/index.html 却出现网页报错406

问题遇到的现象和发生背景

运行tomcat服务器后,打开浏览器输入localhost:8080/index.html

img

img

idea却输出以下语句:


Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@47f4d08b] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.jdbc.JDBC4Connection@6c41c227] will not be managed by Spring
==>  Preparing: select id, username from test_data where id=1 
==> Parameters: 
<==    Columns: id, username
<==        Row: 1, zjz
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@47f4d08b]



我在wepapp里面部署的有使用layui框架的index.html文件,且不开服务器直接通过idea的虚拟服务器运行是没问题的

###### 运行结果及报错内容 

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/460623043246187.png "#left")


我写的Controller如下:

```java
@RestController
public class TestDataController {
    @Resource
    private TestDataService testDataService;

    @RequestMapping("/hello")
    public String hello(){
        return "13213213";
    }
    @RequestMapping
    public List<TestData> selectById(){
        return testDataService.selectById();
}

    @RequestMapping("/testjson")
    public Map<String,Object> testjson(){
        Map<String,Object> map=new HashMap<>();
        map.put("code",0);
        map.put("msg","查询成功咯");
        map.put("count",100);//总计有多少条数据

        List<TestUser> listobj=new ArrayList<>();
        TestUser testUser=null;
        for(int i=0;i<100;i++){
            testUser=new TestUser();
            testUser.setId("0");
            testUser.setUsername("张大帅哥"+i);
            testUser.setEmail("6666666666@qq.com");
            testUser.setSex("男");
            testUser.setCity("xx省xx市");
            listobj.add(testUser);
        }
        map.put("data",listobj);
        return map;
    }


}

运行其他两个,比如localhost:8080/hello,localhost:8080/selectById,都没有问题

我到底问题出在哪儿了,希望大家能帮我看一看,找找问题

其他访问都是通过控制器返回的,index.html文件放在哪里呢?406错误是前台无法解析,参考:
https://blog.csdn.net/qq_43560721/article/details/103595246

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632