当前位置 博文首页 > wsc的博客:SpringMVC请求转发时同时支持.jsp和.html

    wsc的博客:SpringMVC请求转发时同时支持.jsp和.html

    作者:[db:作者] 时间:2021-06-23 21:21

    我的写法是根据springboot受的启发

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    
                <property name = "prefix" value="/"></property>
                                    
                                                //注意了,下面的为空,就是不填
                <property name = "suffix" value = ""></property>
    
            </bean>
    @Controller
    public class MVC {
    //是html文件还是jsp文件要写的具体点
    	@GetMapping("/MVC")
    	public String MVC(Model model){
    		model.addAttribute("Hello","Hello,wsc!");
    		return "JSP/Hello.jsp";
    	}
    
    }

    ?