引导模板& spring boot(无法显示html页面)

时间:2015-05-21 10:25:11

标签: spring twitter-bootstrap spring-mvc

我正在使用引导程序模板和弹簧启动,我想测试控制器,因为我编写了一个简单的restfull服务,它重新调整模板的索引页面,但它不起作用,它给了我一个错误。< / p>

这是项目的架构

enter image description here

这是我的控制器

package demo.controllers;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.view.RedirectView;

import demo.connection.SingletonConnection;
import demo.dao.IDatabase;
import demo.dao.IEntities;
import demo.entities.DB;

@RestController
public class DatabaseController implements ErrorController{
    private static final String PATH = "/error";
    protected Connection conn;
     @Autowired
     private IDatabase db;
     @Autowired 
     private IEntities entities;

    // En cas d'érreur
        @RequestMapping(value = PATH)
        public String error() {
            return "Error";
        }

        @Override
        public String getErrorPath() {
            return PATH;
        }


        @RequestMapping(value="/")
        public String index(Model model){
            return "pages/index.html";
        }    
    }

当我使用路径http://localhost:8080/test

运行应用程序时

0 个答案:

没有答案