web.xml配置:

<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

不要设置为*.do之类,这样只会拦截.do后缀名文件,设置为/,可以拦截所有请求。可以单独给页面设置后缀。如下java代码

然后java代码:

@Controller
public class IndexController {
@RequestMapping("/")
public String index(){
return "/WEB-INF/html/login.html";
}
@RequestMapping("/index.do")
public String index2(){
return "/WEB-INF/html/login.html";
}
@RequestMapping("/index.html")
public String index3(){
return "/WEB-INF/html/login.html";
}
}

controller后不要跟路径,就表示直接是根路径(不带最后斜杠http://localhost:8080/imageModel 个人理解)

然后:

http://localhost:8080/imageModel/

http://localhost:8080/imageModel/index.do

http://localhost:8080/imageModel/index.html

以上都是默认首页。

controller设置路径:

@Controller
@RequestMapping("/invite")
public class InviteController {
@RequestMapping("/getlist")
@ResponseBody
public List<Invite> queryList(){
return biz.queryList();
}
}

表示:http://localhost:8080/imageModel/invite/getlist

spring mvc3+默认首页设置问题的更多相关文章

  1. wampserver 的默认首页设置

    # wampserver 首页顺序设置 <IfModule dir_module> DirectoryIndex index.php default.php index.html inde ...

  2. 将默认首页设置成index.do的方法

    变态欺骗法,今天csdn一个前辈的,学习了,公司服务器是weblogic的,也可以欺骗. 但是我又非常迫切.非常盼望.非常渴望使用index.do做首页,怎么办? Tomcat中用一段注释: When ...

  3. Spring Boot 默认首页

    //继承 WebMvcConfigurerAdapter @Override public void addViewControllers(ViewControllerRegistry registr ...

  4. 指定web默认首页,导致访问路径的问题

    今天写了一个登陆页面,登陆成功跳转时,url中的路径不对 这是目录结构 |-web |---login |-----login.jsp |---success |-----success.jsp 这是 ...

  5. Spring Boot 2.0 设置网站默认首页

    Spring Boot设置默认首页,方法实验OK如下 附上Application启动代码 /** * @ClassName Application * @Description Spring-Boot ...

  6. Spring MVC 程序首页的设置 - 一号门-程序员的工作,程序员的生活(java,python,delphi实战)

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  7. discuz首页设置默认地址不带forum.php后缀的方法

    最近在研究discuz,上传安装几部搞定,打开首页跳到含有"/forum.php"的网址,到管理中心改了好一会儿也没好.那么如何实现discuz首页设置不带forum.php后缀呢 ...

  8. Java Web 设置默认首页

    一.问题描述 这里所谓的默认首页,是指在访问项目根目录时(如 http://localhost:8080/zhx-web/ )展示的页面,通过在web.xml里配置 <welcome-file- ...

  9. Spring Boot默认的JSON解析框架设置

    方案一:启动类继承WebMvcConfigurerAdapter,覆盖方法configureMessageConverters ... @SpringBootApplication public cl ...

随机推荐

  1. POJ3666:Making the Grade——题解

    http://poj.org/problem?id=3666 题目大意:给n个数,每次操作可使一个数+1或-1,求最小操作数使得序列不下降或不上升. —————————————————————— 思路 ...

  2. Codeforces Round #345 (Div. 2) A

    A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  3. Codeforces Round #340 (Div. 2)B

    B. Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  4. 【题解】我也不是B ifrog 1112 二分 倍增

    题目传送门:http://ifrog.cc/acm/problem/1112 神奇的倍增二分,长见识了,在此做个记录,分享给大家. 懒得写题解了,直接转YJQ的:http://ifrog.cc/acm ...

  5. C#学习之泛型功能与限制

    在泛型类的描述中还会有时需要很多限制,例如对待一个泛型类型,在类中定义一个变量需要初始化时,不能确定是用Null还是0. 因为不能够确定它是值类型还是引用类型,这时可以用到default语句(下面有介 ...

  6. 由一篇博文做出的代码,不用Math.round()如何实现其功能

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  7. 实现自己的Promise polyfill

    功能清单: Promise.prototype.then() Promise.prototype.catch() Promise.reject() Promise.resolve() Promise. ...

  8. UVA 1363 Joseph's Problem

    https://vjudge.net/problem/UVA-1363 n 题意:求 Σ  k%i i=1 除法分块 如果 k/i==k/(i+1)=p 那么 k%(i+1)=k-(i+1)*p= k ...

  9. [USACO06NOV] Corn Fields

    https://www.luogu.org/problem/show?pid=1879 题目描述 Farmer John has purchased a lush new rectangular pa ...

  10. jenkins Process leaked file descriptors

    https://stackoverflow.com/questions/17024441/process-leaked-file-descriptors-error-on-jenkins 1. BUI ...