Spring Bootをjarカバンにした時にtemplatesにアクセスしました.エラーやアクセスできませんでした.

859 ワード

Spring Bootをjarカバンにした時にtemplatesにアクセスしました.エラーやアクセスできませんでした.
問題の説明
  • 背景
  • Sprigbootプロジェクトでは、ローカル環境下でファイルにアクセスする方式が図のように構成されています.

  • 問題
  • がjarカバンに打って再度訪問する時、エラーを報告します. 
    This application has no explicit mapping for /error, so you are seeing this as 
    a fallback.
    Wed Mar 06 12:04:46 CST 2019
    There was an unexpected error (type=Internal Server Error, status=500).
    Error resolving template "/login", template might not exist or might not be 
    accessible by any of the configured Template Resolvers
    
  • 解決
  • ページジャンプ制御クラスのパスを変更します. 
    @RequestMapping("/{pagename}")
    public String toPage(HttpServletRequest request, @PathVariable("pagename") String pagename) {
    
        //return "/" + pagename;//idea       
    
        return pagename;// jar       
    
    }