I'm trying to add my custom view and controller to a VERY basic roo-generated project.
By using Spring Tool Suite (STS, Spring 3.1) I created a new project and then ran the following 3 commands:
persistence setup --database MYSQL --provider HIBERNATE --userName *** --password *** --databaseName ***
entity jpa --class com.demoing.domain.Customer --testAutomatically
field string --fieldName firstName --notNull
field string --fieldName lastName --notNull
controller scaffold --class com.demoing.controller.CustomerController --entity com.demoing.domain.Customer
After generating these, the application can be started on the server.
However, when I add a new .jspx file (Like home.jspx) the application says "Resource not found" when going to the specific link. I added to jspx next to other views in src/main/webapp/WEB-INF/views/home.jspx
I've added the view's definition in views.xml and manually created a controller as seen below:
package com.demoing.domain;
import javax.servlet.http.HttpServletRequest;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@Scope(value = "session")
@RequestMapping("/home")
public class HomeController {
@RequestMapping(produces="text/html")
public String home(HttpServletRequest request, Model uiModel ){
return "home";
}
}
And the views definition:
<definition name="home" extends="public">
<put-attribute name="body" value="/WEB-INF/views/home.jspx" />
</definition>
All I want is to display a completely new, empty page. However when I go to "project/home" it says "resource not found".
I really don't understand what I'm missing and I hope someone with a bit more experience with these things can help me out.
Please see the following question and answer on StackOverflow
Adding a custom page in spring roo
Cheers.