Browse Source

app

4_14version
adiao 3 years ago
parent
commit
af7478074d
  1. 17
      app-web/src/main/java/co/depsystem/app/config/MyWebMvcConfig.java
  2. 13
      app-web/src/main/java/co/depsystem/app/demos/web/BasicController.java

17
app-web/src/main/java/co/depsystem/app/config/WebMacConfig.java → app-web/src/main/java/co/depsystem/app/config/MyWebMvcConfig.java

@ -1,30 +1,41 @@ @@ -1,30 +1,41 @@
/**
* @author JOJO
* @class WebMacConfig
* @class MyWebMvcConfig
* @date 2023/3/19
* @apiNote
*/
package co.depsystem.app.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
@Configuration
public class WebMacConfig implements WebMvcConfigurer {
public class MyWebMvcConfig implements WebMvcConfigurer {
/**
* 导入拦截器
* 添加拦截器设置
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
WebMvcConfigurer.super.addInterceptors(registry);
}
/**
* 添加视图配置
*/
@Bean
public ViewResolver viewResolver(){
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/static");
resolver.setSuffix(".html");
return resolver;
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/static/index.html").setViewName("index");

13
app-web/src/main/java/co/depsystem/app/demos/web/BasicController.java

@ -17,10 +17,7 @@ @@ -17,10 +17,7 @@
package co.depsystem.app.demos.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
/** 基本控制器
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
@ -28,6 +25,14 @@ import org.springframework.web.bind.annotation.ResponseBody; @@ -28,6 +25,14 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class BasicController {
/**
* index view
*/
@RequestMapping(value = "/index",method = RequestMethod.GET)
public String index(){
return "index";
}
/**
* <a href="http://127.0.0.1:8080/hello?name=lisi">...</a>
*/

Loading…
Cancel
Save