I saw the relevant questions in stackoverflow but i didn't find a solution to my problem. This is my Initializer Class:
public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
public static HashMap<String, String> response_code = new HashMap<String, String>();
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { MainConfiguration.class };
}
@Override
protected Class<?>[] getServletConfigClasses() {
return null;
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
Security.addProvider(new BouncyCastleProvider());
servletContext.addListener(new MainContextListener());
}
}
This is the Controller:
@RestController
@Component
public class MainController {
@RequestMapping(value = "/getAll", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
public Int addNumber (
@RequestParam(value = "number", defaultValue = "0",
required = false) int number ) {
// code to set and return number
}
}
This is the Structure of webapp folder:
main/webapp/index.jsp
Css and Scripts folders are in webapp folder.
and I'm trying to run the project on intellij using tomcat web server. the problem is when I run the project, index.jsp opens in a browser but it gives 406 not acceptable uri error on getAll.