zoukankan      html  css  js  c++  java
  • springmvc访问项目默认先访问后台再返回首页

    1.spring过滤的url-pattern设置成了/,所以这里随便给个新的后缀

    <welcome-file-list>
      <welcome-file>index.zl</welcome-file>
    </welcome-file-list>

    2.新增一个过滤/index.zl

    <servlet>
            <servlet-name>springmvc</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath:applicationContext.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>springmvc</servlet-name>
            <url-pattern>/index.zl</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>springmvc</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>

    3.controller

    @Controller
    @Scope("prototype")
    @RequestMapping("/index.zl")
    public class IndexController {
    
        @Autowired
        IndexService indexService;
    
        @RequestMapping()
        public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
            
            ModelAndView mv=new ModelAndView();
            return mv;
        }
    
    }
  • 相关阅读:
    swift -- 静态变量static
    swift -- 单例+ lazy懒加载 + 第三方库
    swift -- 代理delegate
    swift -- 闭包
    swift -- 构造/析构函数
    swift -- 继承
    swift -- as / 扩展
    swift -- 类中的方法
    swift -- 类和结构体
    C 扩展库
  • 原文地址:https://www.cnblogs.com/cnsdhzzl/p/7833634.html
Copyright © 2011-2022 走看看