WebWork2 + Spring + Hibernate Getting Started Fully Configuration Guide (1) (Original)

xiaoxiao2021-03-06  40

Webwork is an excellent open source framework, especially its interceptor mechanism, I think it is the biggest highlight of the entire system, you can do a lot of articles on it, eclipse3.0.1 lomoz, database I use mysql4.0.12, Of course, I also used mysqlcc. The server I use Tomcat4.0.3 and Tomcat4.1, please download WebWork., Spring., Hibernate, put the JAR file in the lib directory of Web-INF. At the same time, please download http://unc.dl.sourceforge.net/source.zip, put the aopalliance.jar in the lib directory. There is also webwork2-spring.jar, as well as MySQL drivers to download and put it in Lib, shortness, then configuring log4j, if not properly configuring log, Tomcat will not form your project normally. Configuring log4j is very simple, establish a log4j.properties file under web-inf / class, as follows log4j.rootlogger = info, a1, r log4j.log4j.consolerappender log4j.consoleappender log4j.Appender.a1. Layout = org.apache.log4j.patternLayout log4j.Appender.a1.Layout.conversionPattern =% - D {yyyy-mm-dd hh: mm: s} [% C] - [% P]% m% n log4j.Appender .R = org.apache.log4j.RollingFileAppender log4j.appender.R.File = d: / Tomcat 4.1 / webapps / demo / logs / log4j.log log4j.appender.R.MaxFileSize = 100KB log4j.appender.R.MaxBackupIndex = 1 log4j.Appender.r.Layout = org.apache.log4j.patternLayout log4j.Appender.r.Layout.conversionPattern =% P% T% C -% M% n where the log4j.Appender.r.file This item follows Your Tomcat's installation location is modified, about the details of log4j, I recommend you to see Hilton's learning notes and related articles on IBM websites. Ok, start our webwork. The first is to configure the web.xml file

org.springframework.web.context.contextloaderListener com.atlassian.xWork.ext.resolverseetupservletContextListener Webwork COM. OpenSymphony.WebWork.dispatcher.Servletdispatcher Webwork *. Action Webwork /web-inf/webwork.tld

We configured two listeners, and a servlet, this servlet is responsible for Action's forwarding work, about the detailed working principle of Action, you can see XWork's source code before you first configure, I want to say what I want to implement. Function, it is simple to insert some data into a table in MySQL first. First I use MiddleGen-Hibernate and Hibernate-Extensions (I don't have the Hibernate plugin for Eclipse, I like to generate the table corresponding to HBM.XML Documents and two Java classes, the fields of the table are "Tablename, FieldName, chinesename", the table name is "systable", where TableName, FieldName is dual key key, which, the generated class should be two, a PK primary key class and The primary class itself, I added them into my project. Then I made an interface class package com.cz.struct;

转载请注明原文地址:https://www.9cbs.com/read-66332.html

New Post(0)