Good morning everyone,
I have a question about J2EE framework.
since ASP.net 3.5 mvc add a new feature “Routes” do we have similar function in j2ee ?
here is some text about this feature in asp.net3.5
Routes are a new feature in .NET 3.5 SP1, and ASP.NET MVC uses this feature to give controller classes the capability to respond to requests. ASP.NET MVC uses REST-like URLs (Representational State Transfer) that are cleaner than regular ASP.NET web application URLs. Here are examples of such URLs:
/products/show/881
/customers/list
/login/register
As you can see, REST-like URLs tend to be clean, simple, and don’t expose .aspx files directly on the server. Although you can have directly addressed .aspx pages in ASP.NET MVC applications, this is not the main idea.
Through developer-defined routes, the ASP.NET MVC application can direct requests to controllers. Routes are defined once for the entire ASP.NET application, so the Global.asax file is the logical place to define these. In fact, if you take a look at the default Global.asax.cs file in an ASP.NET MVC application, you will see a method called RegisterRoutes defined. This method is called from the Application_Start method, and implemented like this:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home",
action = "Index",
id = "" }
);
}
By default, a route called “Default” is defined with three parts: controller, action, and finally an ID separated by slashes. When a request arrives at the MVC application, the URL is parsed according to this definition. For instance, given the request for “/products/show/881”, this would be parsed so that the “controller” parameter would have the value of “products”, the “action” parameter would be “show”, and finally the “id” would be “881”.
If you use Spring, you can use it’s @RequestMapping annotations to achieve something similar, so you could have something like
And if you want to make sure that jsps can’t be directly called, you place them inside WEB-INF