body
{
font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI",Tahoma,Helvetica,Sans-Serif,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLiU,serif;
font-size: 10.5pt;
line-height: 1.5;
}
html, body
{

}
h1 {
font-size:1.5em;
font-weight:bold;
}
h2 {
font-size:1.4em;
font-weight:bold;
}
h3 {
font-size:1.3em;
font-weight:bold;
}
h4 {
font-size:1.2em;
font-weight:bold;
}
h5 {
font-size:1.1em;
font-weight:bold;
}
h6 {
font-size:1.0em;
font-weight:bold;
}
img {
border:0;
max-width: 100%;
}
blockquote {
margin-top:0px;
margin-bottom:0px;
}
table {
border-collapse:collapse;
border:1px solid #bbbbbb;
}
td {
border-collapse:collapse;
border:1px solid #bbbbbb;
}

Spring MVC 程序首页的设置 - 一号门-程序员的工作,程序员的生活(java,python,delphi实战)在用 Spring mvc 写程序,配置 DispatcherServlet 拦截规则为拦截所有(
<url-pattern>/</url-pattern>
)时,应用程序首页的定义很有可能出问题,在项目中一般来说有如下几种解决办法.

1. 在 webcontent 下定义一个首页. index.jsp 或者 index.html ,然后跳转到controller 处理.
这种情况下,通常会像如下这样处理

程序代码

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

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

而在index.jsp 里面通常会这么写:

程序代码

<head>
  <meta http-equiv="Refresh" content="0; URL=/mycontroller/test">
</head>

这样,就推跳转到 mycontroller/test 去处理。

方法 2:交给 spring mvc  controller 去处理,不要配置默认首页  
首先,不要配置首页, 必须设置成如下:

程序代码

<welcome-file-list>
    <welcome-file></welcome-file>
</welcome-file-list>

这样,web 服务器就知道,不需要他来处理,而是由应用程序自己来处理。这个时候,spring mvc 的 servlet 配置就起作用了,可以如下配置:

程序代码

<mvc:view-controller path="/" view-name="redirect:/mycontroller/test" />

这种配置方式下,效果与前面的一样,都是类似于 redirect 做到的。

最新文章

  1. nodejs pm2部署配置
  2. 批量导出oracle中的对象
  3. 9.7 js进阶总结2
  4. RDIFramework.NET 框架之组织机构权限设置
  5. 【Pro ASP.NET MVC 3 Framework】.学习笔记.1.主要语言特性
  6. Java 多线程中run() 与 start() 的不同
  7. 【pyhton】【转】修改递归次数
  8. BZOJ1895: Pku3580 supermemo
  9. linux之sed用法【转载】
  10. 全文搜索之 Elasticsearch
  11. 推荐一个比FiddlerCore好用的HTTP(S)代理服务器
  12. 对JS prototype的理解
  13. 读写分离子系统 - C# SQL分发子系统(目前只支持ADO.NET)
  14. cf里的一些简单组合数题
  15. CI集成 mesos 资源分配的思考, 待续
  16. php服务器代理解决浏览器跨越问题
  17. node库的选择
  18. 第01章:MongoDB简介
  19. Vim 操作命令不完全汇总
  20. 平衡二叉树,AVL树之代码篇

热门文章

  1. hh monitor
  2. icon大小
  3. AngularJS中如果ng-src 图片加载失败怎么办
  4. b端商家赋值权限
  5. URL的# (转)
  6. CGRect相关工具函数
  7. C、C++、java的区别
  8. execlp(&quot;ls&quot;,&quot;flw&quot;,&quot;-?&quot;,(char *)0) 为什么少了最后的一个参数就不行?
  9. Swift 使用Extension 场景 浅析
  10. 初识Selenium(一)