I'm trying to run my web application based on javax.mvc
, but I get 404 error. I think there should be an issue related to the application path, but I don't know exactly what's wrong.
XAMPP is installed and IntelliJ idea is configured to run tomcat7 as the web server.
Application code:
@ApplicationPath("web")
public class StoreApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> set = new HashSet<>();
set.add(ProductController.class);
return set;
}
}
Controller:
@Controller
@Path("products")
public class ProductController {
@Inject
private Models models;
@GET
public String list() {
models.put("products", Product.list());
System.out.println("helllo");
return "/WEB-INF/jsp/list.jsp";
}
}
This is a maven project. The build process is done with IntelliJ idea default settings.
Base url is set in StoreApplication.java
as web
with application path.
The war url is http://localhost:8080/elearning_war/ as depicted in the picture.
And the controller path is products
. So I expect to show a list of products in http://localhost:8080/elearning_war/web/products
, but instead, I get a 404 error page.