There are a lot of friends who are currently engaged in struts development. Some small details may help you improve development efficiency, especially in looking for JSP.
During Struts-based development, some friends use tiles, and some others do not. The following figure shows the code at the bottom of the baseaction.exe cute (...) method to help you find the location of the JSP page and print it to the console.
1. Do not use tiles:
Actionforward AF = super.exe cute (mapping, form, request, response );
System. Out. println ("You are accessing JSP is:" + Af. getpath ());
Return AF;
2. Use tiles:
Actionforward AF = super.exe cute (mapping, form, request, response );
Definitionsfactory factory = (tilesutilstrutsimpl) tilesutil
. Gettilesutil (). getdefinitionsfactory (request, Servlet. getservletcontext ());
Componentdefinition definition =
Factory. getdefinition (
Af. getpath (),
Request,
Servlet. getservletcontext ());
If (definition! = NULL ){
System. Out. println ("You are processing to:" + Af. getpath ());
Map map = definition. getattributes ();
Iterator iter = map. keyset (). iterator ();
While (ITER. hasnext ()){
String key = (string) ITER. Next ();
String JSP = (string) map. Get (key );
System. Out. println ("" + key + ":" + JSP );
}
} Else {
System. Out. println ("You are processing to:" + Af. getpath ());
}
Return AF;
In this way, when you run the system, click a page and the console displays the corresponding information, which is much more convenient.