代碼無法運行,一直404
package com.dtb;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by Administrator on 2017/5/27 0027.
*/
@RestController
public class Indexcontroller {
? ?@RequestMapping(value = "/index",method = RequestMethod.GET)
? ?public String say(){
? ? ? ?return "hello Spring boot";
? ?}
}
2017-06-06
樓上正解,沒有配置的話,不需要加項目名稱
2017-05-27
你要在main方法中執行下面的方法 ?
而不是啟動tomcat,如果運行這個方法啟動沒有報錯,例如端口占用,并且沒有配置訪問項目的名稱的話,那么你訪問localhost:8080/index 就能執行到你這個方法了,如果你配置了,就訪問localhost:8080/項目名/index