I try put 2 request mapping since i want to point to home/home since later i will be having another controller with same name which is about/home. But i not sure why it was not working. If have only home it is working but home/home or about/home not working. The class level not working.
This the controller
package com.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.constant.server.HelperConstant;
@Controller
@RequestMapping("/home")
public class HomeController
{
@RequestMapping("/home")
public String doDisplayPage()
{
return HelperConstant.VIEW_HOME;
}
}
This the jsp
<html>
<body>
<form action="home/home">
<input type="text" name="t1"><br>
<input type="text" name = "t2"><br>
<input type ="submit">
</form>
</body>
</html>
I am hitting HTTP Status 404 -
Edited
Attached the config files
package com.config;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
public class WebConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
// TODO Auto-generated method stub
return null;
}
@Override
protected Class<?>[] getServletConfigClasses() {
// TODO Auto-generated method stub
return new Class[] {SpringConfig.class};
}
@Override
protected String[] getServletMappings() {
// TODO Auto-generated method stub
return new String[] {"/"};
}
}
This another config file
package com.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
@Configuration
@ComponentScan({"com.controller"})
public class SpringConfig
{
@Bean
public InternalResourceViewResolver viewResolver()
{
InternalResourceViewResolver vr = new InternalResourceViewResolver();
//vr.setPrefix("/WEB-INF/");
vr.setSuffix(".jsp");
return vr;
}
}
Attached the picture of the folder structure

there is an additional findings as well whereby i trying to look for the jsp at home/home.jsp. can i know why such behaviour? by right should just look at home.jsp. If remvoe class level anotation, then it working fine or i create a folder inside webapp home it working fine but after click submit again it looks for home/home/home.jsp
I have added a method="POST"
now problem is after restart tomact
after click submit like this
if click submit again show eror 404
this my web.xml but i removed it already since i already use java or configurtion
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<welcome-file-list>
<welcome-file>home.html</welcome-file>
<welcome-file>home.htm</welcome-file>
<welcome-file>home.jsp</welcome-file>
</welcome-file-list>
</web-app>




form action="home"?/home/homeforactionattribute?