Struts under Tomcat, and uses UsertransAction for transaction operations. I use Struts1.1. 1: Use the useertransaction to use the JOTM package 1 in jotm-1.4.3.tar when using UserTransaction. About Tomcat Server.xml TYPE = "javax.sql.datasource" /> type = "javax.transaction.UserTransaction" /> }} 2: Extending an actionMApping.java class, you can set whether log information is logged when developed. 1. Extended ActionMapping.java class import org.apache.struts.Action.ActionMapping; Public class myActionmapping extends actionmapping {// addressmapping {// addressMAPPING = false; // Call the an actionMapping's default constructor public saapactionmapping () {super ();} Public Boolean islogresults () {return logresults;} public void setLogResults (Boolean LogResults) {this.logResults = LogResults;}} 2. Configure struts-config.xml, where Public ActionForward Execute (ActionMapping Mapping, Actionform Form, HTTPSERVLETREQUEST Request, httpservletresponse response) throws exception {myActionMapping mymapping = (myActionmapping) mapping; IF (mymapping.islogresults ()) {system.out.println ("islogResults =====);} // Transaction operation try {useertran.begin (); System.out.println ("00000000"); string SQL1 = "INSERT INTO TEST VALUES (21, '21 ', sysdate"; jdbc.executeUpdate (SQL1); System.out.Println ("11111111"); string SQL2 = "INSERT INTO TEST VALUES (33, '33', sysdate"; jdbc.executeUpdate (SQL2); System.out.Println ("2222222"); string sql3 = "Insert Into Test Values (51, '51 ', sysdate) "; jdbc.executeUpdate (SQL3); System.Out.println (" 33333333 "); userTRAN.Commit ();} catch (exception e) {usertran.rollback (); system.out.println (" 44444444 " } Return mapping.findforward ("success");}} 3: Extension to the Struts platform, you can perform permission control on the platform, extend the requestProcessor.java class. In this class, you can use as long as the ProcessPreProcess method is expanded. public class MyRequestProcessor extends RequestProcessor {/ ** * Process an // Wrap Multipart Requests with a Special Wrapper Request = ProcessMultipart (Request); // Identify The Path Component We Will Use to SELECT A MAPPING String path = processPath (request, response); System.out.println ( "33333333333333333333333 =" path); if (path == null) {return;} if (log.isDebugEnabled ()) {log.debug ( "Processing A '" Request.getMethod () "' for path '" PATH " ");} // select a local for the current user if Requested ProcessLocale (Request, Response); // set the content type and no-caching headers if Requested processcontent (request, response); processnocache (request, response); // General Purpose PreProcessing Hook if (! Process, response)) {path = "/ fail"; system.out.println ("1111111111 =" path); // Return;} // identify the mapping for this request actionMApping mapping = processmapping (required); if (mapping == null) {return;} // Check for any role required to perform this action if (! Process, response, mapping) {return;} // Process any ActionForm bean related to this request ActionForm form = processActionForm (request, response, mapping); processPopulate (request, response, form, mapping); (! ProcessValidate (request, response, form, mapping)) if {return; } // process a forward or include specified by this mappingiff (! Process,}) {return;}}}}}} {Return;} // Create or acquire the action instance to process this request action action = processActioncreate (request, response, mapping); if (action == null) {return;} // Call the Action instance itself ActionForward forward = processActionPerform (request, response, action, form, mapping); // Process the returned ActionForward instance processForwardConfig (request, response, forward); } / ** * General-purpose preprocessing hook that can be overridden as required * by subclasses. Return Protected Boolean ProcessPreprocess (httpservletRequest Request, HttpservletResponse response) {httpsession session = request.getSession (); // string ss = (string) session.getattribute ("ss"); string ss = "sdfds"; system.out.println ("------ --------------- processpreprocess = " ss); if (ss! = null) {Return (TRUE);} else {returnaf false;} } } HttpServletRequest code> and create the * corresponding
HttpServletResponse code>. p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * * @exception IOException if an input / output error occurs * @exception ServletException if a processing exception occurs * / public void process (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
true code> if you want standard processing * to continue, or
false code> if the response has Already Been * Completed. The default usmentation does Nothing. * @Param Request the servlet request we are processing * @Param response the servlet response we are creating * /