部署jar上的错误解决模板或春季启动时出现战争

时间:2018-07-08 09:12:37

标签: spring-boot jar war

当我在嵌入式tomcat服务器上运行我的应用程序时,一切都很好。 但是当我在其他服务器或容器上部署jar或war时,某些URL上的服务器给我错误: 解决模板“ / shop / index”时出错,该模板可能不存在,或者任何配置的模板解析器都无法访问该模板

这是我的application.yml:

    server:
  port: 8080
logging:
    level:
        com.mousavi007.shop: debug
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/shop2
    username: *******
    password: *******
    platform: mysql
  jpa:
    hibernate:
      ddl-auto: update
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    database: mysql
    show-sql: true
  thymeleaf:
      mode: LEGACYHTML5

商店控制器:

@Slf4j
@Controller
@RequestMapping("/shop")
public class ShopController {

@GetMapping({"","/"})
    public String Shop(Model model, @RequestParam("pageSize") Optional<Integer> pageSize,
                       @RequestParam("page") Optional<Integer> page){
**** 
****
****
****
            return "/shop/index";
}
}

1 个答案:

答案 0 :(得分:0)

更改

<?php

    /* Process ajax request */
    if( $_SERVER['REQUEST_METHOD']=='GET' && isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && $_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest' ){
        ob_clean();

        $args=array(
            'category'      =>  FILTER_SANITIZE_STRING,
            'datePeriod'    =>  FILTER_SANITIZE_STRING
        );
        $_GET = filter_input_array( INPUT_GET, $args );
        extract( $_GET );


        echo $category . ' ' . $datePeriod;
        /* process these variables to construct your sql query */

        exit();
    }
?>
<!doctype html>
<html>
    <head>
        <meta charset='utf-8' />
        <title>ajax filtering idea</title>
        <script>
            document.addEventListener('DOMContentLoaded',function(){
                /* Create a nodelist collection of select menus according to class "filter" */
                var col=document.querySelectorAll( 'select.filter' );

                /* Placeholder object to store the state of any menu that is changed */
                var states={};

                /* Iterate through nodelist collection and assign event listener to each */
                Array.prototype.slice.call( col ).forEach( function( menu ){

                    /* store initial state of all menus */
                    states[ menu.name ]=menu.value;

                    menu.addEventListener('change',function(e){
                        /* store this menu name & value after change */
                        states[ e.target.name ]=e.target.value;

                        /* send ajax request */
                        ajax.call( this, location.href, states, callback )
                    },false );
                });
            },false);

            /* basic ajax function */
            function ajax( url, payload, callback ){
                var xhr=new XMLHttpRequest();
                var params=[];
                for( var p in payload )params.push( p + '=' + payload[ p ] );

                xhr.onreadystatechange=function(){if( this.readyState==4 && this.status==200 )callback.call( this, this.response );};
                xhr.open( 'GET', url + '?' + params.join('&'), true );
                xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');
                xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                xhr.send( null );
            }
            /* very simple callback */
            var callback=function(r){
                document.getElementById('output').innerHTML=r
            };
        </script>
    </head>
    <body>
        <div class="col-lg-6">                                
           <select class="form-control filter" name="category" id="category">
               <option>All</option>
               <option>Abraham</option>
               <option>Kevin</option>
               <option>Eric</option>
           </select>                                
        </div>   
        <div class="col-lg-6">                                
           <select class="form-control filter" name="datePeriod" id="datePeriod">
               <option>Today</option>
               <option>Yesterday</option>
               <option>Last 7 days</option>
               <option>Last month</option>
               <option>Last year</option>
           </select>                                
        </div>
        <div class="col">
           <div id="output"></div>
        </div>
    </body>
</html>

return "/shop/index";