发表于: 2018-03-03 23:55:04

0 808


今天完成的事情:

1. 看springboot


明天计划的事情

1.学习springboot



遇到的问题:

<dependency>
 <groupId>mysql</groupId>
 <artifactId>mysql-connector-java</artifactId>
 <version>6.0.6</version>
</dependency>

6版本以上会出现时区问题,

java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.


需要做约束:

而且:  .yml文件key-value 之间要有空格格开," : "冒号后要有空格



2. 如果想要springboot的tomcat 支持jsp,除了一般的JSP的jar包还需要:

<!-- springboot里要用tomcat显示JSP必须要这个JAR -->
<dependency>
 <groupId>org.apache.tomcat.embed</groupId>
 <artifactId>tomcat-embed-jasper</artifactId>
</dependency>



收获:

1. @Controller @RestController

1)@RestController注解Controller,则Controller中的方法无法返回jsp页面,配置的视图解析器InternalResourceViewResolver不起作用,返回的内容就是Return 里的内容。
2)如果需要返回到指定页面,则需要用 @Controller配合视图解析器InternalResourceViewResolver(ModelAndView)才行。

@Controller类中的方法可以直接通过返回String跳转到jsp、ftl、html等模版页面。在方法上加@ResponseBody注解,也可以返回实体对象
@RestController类中的所有方法只能返回String、Object、Json等实体对象,不能跳转到模版页面。
@RestController相当于@ResponseBody + @Controller。







返回列表 返回列表
评论

    分享到