Spring Boot cannot render jsp file
Chào anh ạ, em đang học về Spring Boot và đang gặp vấn đề ở việc render file jsp. Như trong hinh, em đã set up cho chạy vào class HomeController nhưng không hiểu sao ở chỗ return "home", nó lại không render home.jsp. Dưới đáy là code của em. Mong anh có thể giúp em ạ.
java
spring boot
Remain: 5
4 Answers
khanhchuong
Beginner
khanhchuong
Beginner
Dạ đây ạ
<img class="alignnone size-full wp-image-592" src="https://stackask.com/wp-content/uploads/2021/08/6.jpg" alt="" /> <img class="alignnone size-full wp-image-591" src="https://stackask.com/wp-content/uploads/2021/08/5.jpg" alt="" /> <img class="alignnone size-full wp-image-590" src="https://stackask.com/wp-content/uploads/2021/08/4.jpg" alt="" /> <img class="alignnone size-full wp-image-589" src="https://stackask.com/wp-content/uploads/2021/08/3.jpg" alt="" /> <img class="alignnone size-full wp-image-588" src="https://stackask.com/wp-content/uploads/2021/08/2.jpg" alt="" />
<img class="alignnone size-full wp-image-587" src="https://stackask.com/wp-content/uploads/2021/08/1.jpg" alt="" />
-
0
tvd12
Enlightened
tvd12
Enlightened
Em có thể dẩy code lên git được không? nếu không được anh sẽ tự tạo project cũng được em ạ
-
0
tvd12
Enlightened
tvd12
Enlightened
Vậy anh hướng dẫn em sử dụng github trước nhé, vì chắc sẽ còn nhiều lần em cần anh support nữa.
- Em tạo tài khoản trên trang này nhé <a href="https://github.com/" rel="nofollow ugc">https://github.com/
- Sau đó em tạo một repository nhé
Xong em báo anh, anh sẽ teamview và hướng dẫn em sử dụng tiếp nhé
-
0
tvd12
Enlightened
tvd12
Enlightened
issue này em ạ
, như vậy hiện tại em không thể chạy được bằng hàm main em ạ, em phải sửa lớp
DemoApplication thành thế này để có thể chạy qua tomcat em ạ:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(DemoApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
Em thử sửa rồi chạy với tomcat xem sao em nhé, có lỗi anh lại support tiếp nhé
-
0