Monday, 15 June 2015

spring - how do you create 2 servlets within one web.xml file? -



spring - how do you create 2 servlets within one web.xml file? -

this code 1 servlet in web.xml file:

<context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/applicationcontext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>redirect.jsp</welcome-file> </welcome-file-list>

can re-create , paste , alter values , utilize again?

second question (which may help reply first)

currently when deploy application in glassfish url localhost/hellospring 404. however, when add together /home on end so: localhost/hellospring/home goes right page. can add together /index localhost/hellospring/index on end , works correctly too. how can load localhost/hellospring/home startup rather having type in manually , avoiding 404 error?

note: when changing url pattern / /home in servlet mappings, fixes /home problem means /index not work

so in summary, how can load localhost/home deployment , type in index url /index , display right page?

p.s. stackoverflow not allow me type in total address links assume have said localhost contains port :8080 straight after

your servlet not recognize automatically home page. have tell either using redirect page (you include in welcome-file-list), or map controller serves home page root well:

@requestmapping(value = { "/", "/home" }, method = requestmethod.get)

xml spring spring-mvc servlets web

No comments:

Post a Comment