Java – spring welcome file list mapped correctly
•
Java
I know that in spring, I must define the welcome file, which should be outside the WEB-INF folder, so I define it as follows:
web. In XML:
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
But actually my real code is in WEB-INF / JSP / contact jsp
So I always do this:
<jsp:forward page="/index"></jsp:forward>
In my controller, this means:
@RequestMapping("/index") public String listContacts(Map<String,Object> map) { map.put("contact",new Contact()); map.put("contactList",contactService.listContact()); return "contact"; }
How can I do this? The welcome file always goes to my index mapping, which leads to contact jsp?
Ask questions at any time. If this is chaotic
Solution
@RequestMapping({"/index","/"})
@RequestMapping({"/index","/"})
and
<welcome-file-list> <welcome-file></welcome-file> </welcome-file-list>
Work for me
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码