model view controller - Root Context path in spring application -


i running application using tomcat server, when server start url

http://localhost:8080/testapp/

and displaying index.jsp file when click link in index file displaying url like

http://localhost:8080/testsuccess

but should display like

http://localhost:8080/testapp/testsuccess

can please me solve this.

springconfiguration.java

@configuration @enablewebmvc @componentscan("com.testapp") @enabletransactionmanagement public class springconfiguration {    @bean    public internalresourceviewresolver viewresolver() {     internalresourceviewresolver viewresolver = new internalresourceviewresolver();     viewresolver.setprefix("/web-inf/views/");     viewresolver.setsuffix(".jsp");     return viewresolver; } } 

springwebappinitializer.java

public class springwebappinitializer implements webapplicationinitializer {

@override public void onstartup(servletcontext container) throws servletexception {     annotationconfigwebapplicationcontext appcontext = new annotationconfigwebapplicationcontext();     appcontext.register(springconfiguration.class);     servletregistration.dynamic dispatcher = container.addservlet(             "springdispatcher", new dispatcherservlet(appcontext));     dispatcher.setloadonstartup(1);     dispatcher.addmapping("/"); }  } 

mycontroller.java

@controller public class myfirstcontroller   {  @requestmapping(value = "/" , method = requestmethod.get) public string testapp() throws exception{     return "index"; }  @requestmapping(value = "/testsuccess", method = requestmethod.get) public string testappsuccess() {     map<string, object> model = new hashmap<string, object>();     return "success"; }  } 

got should use

 <a href="<c:url value='/testsuccess'/>">next</a>  

it give context path.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -