j2ee笔记.docx

上传人:b****7 文档编号:8791441 上传时间:2023-02-01 格式:DOCX 页数:43 大小:34.35KB
下载 相关 举报
j2ee笔记.docx_第1页
第1页 / 共43页
j2ee笔记.docx_第2页
第2页 / 共43页
j2ee笔记.docx_第3页
第3页 / 共43页
j2ee笔记.docx_第4页
第4页 / 共43页
j2ee笔记.docx_第5页
第5页 / 共43页
点击查看更多>>
下载资源
资源描述

j2ee笔记.docx

《j2ee笔记.docx》由会员分享,可在线阅读,更多相关《j2ee笔记.docx(43页珍藏版)》请在冰豆网上搜索。

j2ee笔记.docx

j2ee笔记

UML½¨Ä£¹¤¾ß£ºkdesdk-umbrello

linuxÏÂeclipse,tomcatÕûºÏ£º

²½ÖèÒ»£º½«ÏÂÔصÄtomcat½âѹµ½eclipse/pluginsĿ¼£¬Ö®ºó´ò¿ªeclipse

²½Öè¶þ£ºFile-->New-->OtherÕ¹¿ªServer-->Server-->NextÕ¹¿ªApache-->Ë«»÷Ñ¡ÔñTomcatv8.0Server-->Next

µãBrowser...Ñ¡ÔñtomcatµÄλÖÃ-->È·¶¨-->Finish

1.(eclipsetomcat)javax.servlet.http.httpservlet²»´æÔÚ

--------µ½tomcatµÄ°²×°Â·¾¶ÏÂ\lib\servlet-api.jar¸´ÖƵ½WEB-INF/libÏ£¬È»ºóµãÏîÄ¿Ãû°´F5£¬Ó¦¸Ã¾ÍOKÁË

2.Æô¶¯tomcatÔËÐÐjspʱ³öÏÖ“WARNING:

[SetContextPropertiesRule]{Context}Settingproperty'source'to'org.eclipse.jst.jee.server:

HelloWorld'didnotfindamatchingproperty.”

--------³öÏÖSetPropertiesRule¾¯¸æµÄÔÒòÊÇÒòΪTomcatÔÚserver.xmlµÄContext½ÚµãÖв»Ö§³ÖsourceÊôÐÔ£º

½â¾ö·½·¨ÊÇÔÚServersÊÓͼÀïË«»÷´´½¨µÄserver£¬È»ºóÔÚÆäserverµÄÅäÖýçÃæÖÐÑ¡ÖÐ"PublishmodulecontextstoseparateXMLfiles"Ñ¡Ïî¡£

JAXBÀà¿â´¦Àíxml£ºÏÂÔØJAXB£¬½âѹ£¬½«ÆäϵÄbinĿ¼¼ÓÈ뵽ϵͳ»·¾³±äÁ¿

-------------------------------------------------------

ÔËÐÐservletÀࣺ

½¨Á¢HelloServlet.java£¨¼Ì³ÐservletÀࣩ,ÓÒ¼üµ¥»÷DepolymentDesciptorÖеÄServlets£¬Ñ¡ÕßNew->Servlet->Ñ¡ÖÐUseexistingServletclass£¬È»ºóµ¥»÷Browse...°´Å¥£¬Ñ¡ÔñHeloServletÀ֮࣬ºó¾Í¿ÉÒÔͨ¹ýä¯ÀÀÆ÷·ÃÎÊ¡£

-----------------------------------------------------

Jstl±êÇ©¿â£º

---×é³É£ºËĸö¶¨ÖƱêÇ©¿â£¨core¡¢format¡¢xml¡¢sql£©¡¢Ò»¶ÔͨÓñêÇ©¿âÑéÖ¤Æ÷£¨ScriptFreeTLV¡¢PermittedTaglibsTLV£©

------------------------------------------------------------------------

±êÇ©¿âµØÖ·×÷ÓÃ

----------------------------------------------------------------------------------

CoreÖ§³ÖJSPÖеÄһЩ»ù±¾²Ù×÷

------------------------------------------------------------------------------

XmlÖ§³ÖXMLÎĵµµÄ´¦Àí

-------------------------------------------------------------------------------

FormatÖ§³Ö¶ÔÊý¾ÝµÄ¸ñʽ»¯

----------------------------------------------------------------------------

SQLÖ§³ÖJSP¶ÔÊý¾Ý¿âµÄ²Ù×÷

ÔÚeclipseÖÐн¨DynamicWebProject£¬Ö®ºó°ÑÏÂÔصÄJSTL°ü½âѹ£¬½«ÀïÃæµÄjarÎļþ¸´ÖƵ½tomcatĿ¼ÏµÄlibĿ¼ÖУ¬²¢½«tldÎļþ¸´ÖƵ½¸Õ´´½¨µÄWebProjectÏîÄ¿µÄWEB-INFĿ¼ÖУ¬Ö®ºóÐÞ¸ÄWebContent.WEB—INFĿ¼ÏµÄweb.xmlÎļþ£¬Ìí¼Ó8¸ö±êÇ©¿âµÄ±íÏî()£º

xmlversion="1.0"encoding="UTF-8"?

>

xmlns="

xmlns:

xsi="http:

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="

/WEB-INF/fmt.tld

/WEB-INF/fmt-rt.tld

/WEB-INF/c.tld

/WEB-INF/c-rt.tld

/WEB-INF/sql.tld

/WEB-INF/sql-rt.tld

/WEB-INF/x.tld

/WEB-INF/x-rt.tld

Ö®ºó´´½¨jspÎļþ²âÊÔ£¬ÐëÔÚÒ³ÃæÉÏÉùÃ÷ʹÓÃJSTLµÄcore±êÇ©¿â£º

<%@tagliburl="prefix="c"%>

------------------------------------------------------------------

struts¿ò¼Ü£º4¸öºËÐÄ×é¼þ£ºActionServlet(¼Ì³Ðjavax.servlet.http.HttpServletÀà),

ActionClass£¨¿Í»§ÇëÇó¶¯×÷ºÍÒµÎñÂß¼´¦ÀíÖ®¼äµÄÒ»¸öÊÊÅäÆ÷Adapter,¼Ì³ÐActionÀࣩ,

ActionMapping,

ActionFormBean£¨·Ç³Ö¾ÃÐÔÊý¾Ý´æ´¢£©

ÔÚeclipseÖÐн¨DynamicWebProject£¬Ö®ºó°ÑÏÂÔصÄStruts1.2.7°ü½âѹ£¬½«ÀïÃæµÄjarÎļþ¸´ÖƵ½WebContent/WEB-INFĿ¼ÏµÄlibĿ¼ÖУ¬Ö®ºóÅäÖÃWebContent.WEB—INFĿ¼ÏµÄweb.xmlÎļþ(ÅäÖù¤×÷¿ÉÒÔÔÚÒ»¸öÎļþÖнøÐУ¬Ò²¿ÉÒÔÔÚ¶à¸öÎļþÖнøÐУ¬Èç¹û²ÉÓõ¥ÅäÖÃÎļþµÄ·½Ê½£¬Ò»°ãÊDZàдStruts-config.xml£¬ÎļþÃûÓÉweb.xmlÎļþ¶¨Òå):

--servletµÄÃû³Æ-->

action

--servletËùÔÚµÄλÖÃ-->

org.apache.struts.action.ActionServlet

--servletÆô¶¯Ê±µÄ²ÎÊý-->

--¶¨ÒåstrutsµÄÅäÖÃÎļþ-->

config

/WEB-INF/struts-config.xml

--¶¨ÒådebugµÄ¼¶±ðΪ2-->

debug

2

--¶¨ÒådetailµÄ¼¶±ðΪ2-->

detail

2

2

×¢Ò⣺ΪÁË°æ±¾¿ØÖÆ·½±ã£¬±ÜÃâÓ·Ö׵ĵ¥¶Àstruts-config.xmlÎļþ£¬×îºÃ²ÉÓöà¸öÅäÖÃÎļþ£¬Ã¿¸ö¿ª·¢Õßֻά»¤×Ô¼ºµÄÅäÖÃÎļþ

ÅäÖÃStruts-config.xml:

xmlversion="1.0"encoding="UTF-8"?

>

"http:

//jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"

--NOTE:

IFyouhavaageneratortooltocreatethecorrespondingJavaclassesforyou,youcouldincludethe

detailsinthe"form-bean"elementitself.withthecorresponding"name"and"type"attributes,asshownhere.

-->

--ÅäÖÃforembean-->

--ÅäÖÃÈ«¾ÖÒì³£-->

--µ±ExceptionÒì³£Å׳öʱ£¬Ìøתµ½globalerror.jspÒ³Ãæ-->

--=====================ActionMappingDefinitions-->

--ÅäÖÃactionmapping-->

--======================ControllerConfiguration-->

--Titles-->

--ÅäÖÃÏûÏ¢×ÊÔ´Îļþ-->

--======================PlugInsConfiguration-->

--=============Titlespugin================-->

--

ThisplugininitializeTitlesdefinitionfactory.Thislatercantakessomeparamtersexplainedhereafter.

Thepluginfirstreadparamtersfromweb.xml,thenoverloadthemwithparamtersdefinedhere.Allparamtersareoptional.

Thepluginshouldbedeclaredineachstruts-configfile.

-definitions-config:

(optional)

Specifyconfigurationfilenames.Therecanbeseveralcommaseparatedfilenames(degalut:

?

?

-moduleAware:

(optional-struts1.1)

SpecifyiftheTitlesdefinitionfactoryismoduleaware,iftrue(default),therewillbeonefactoryforeachStrutsmodule.

Iffalse,therewilllbeonecommonfactoryforallmodule.Inthislatercase,

itisstillneededtodeclareonepluginpermodule.

Thefactorywillbeinitializedwithparamtersfoundinthefirstinitializedplugin(generallytheoneassociatedwiththe

defaultmodule).

true:

Onefactorypermodule.(default)

falase:

onesinglesharedfactoryforallmodules

-definitions-parser-validate:

(optional)

SpecifyifxmlparsershouldvalidatetheTitlesconfigurationfile.

ture:

validate.DTDshouldbespecifiedinfileheader.(default)

false:

novalidation

PathsfoundinTitlesdefinitionsarerelativetothemaincontext.

-->

--commentfollowingifstruts1.0.x-->

--ÅäÖÃTitles²å¼þ-->

--ÅäÖÃvalidator²å¼þ-->

=======================================================================

struts2¿ò¼Ü:

ÏÂÔØ×îа汾Struts2.5.2(Ò»°ãÏÂÔØËùÐèÒªµÄlib°ü¼´¿É),н¨DynamicWebProjectÏîÄ¿(×¢ÒâÒª½«Defaultoutputfolder¸ÄΪWebContent/classes£¬ÇÒѡΪ×Ô¶¯Éú³Éweb.xmlÎļþ)£¬½«ÏÂÔصÄStruts2/apps/struts2-bank/libϵÄjarÎļþ¸´ÖƵ½ÏîĿϵÄWebContent/WEB-INF/libÏ£¬

Ö®ºó½«Struts2/apps/struts2-bankʾÀýÎļþÖÐweb.xmlÖеÄfilter±êÇ©¡¢filter-mapping±êÇ©µÄÄÚÈÝcopyµ½ÏîÄ¿µÄweb.xmlÎļþÖУ¬²¢½«Struts2/apps/struts2-bankʾÀýÎļþÖеÄstruts.xml¸´ÖƵ½ÏîÄ¿µÄsrcĿ¼Ï¡£

·ÃÎÊWEBÔªËصÄËÄÖÖ·½·¨£º

//È¡µÃMapÀàÐÍ£ºrequest£¬session£¬application£¨µÚÒ»£¬¶þÖÖ·½·¨£©

//È¡µÃhttpÀïµÄÌØÊâ·½·¨£ºHttpServletRequest,HttpSession,ServletContext£¨µÚÈý£¬ËÄÖÖ·½·¨£©

µÚÒ»ÖÖ£º£¨ÒýÓÃActionContextÀࣩ

publicclassLoginActionextendsActionSupport{

privateMaprequest;

privateMapsession;//³£³£»ñÈ¡session

privateMapapplication;

publicLoginAction(){

request=(Map)ActionContext.getContext.get(“request”);

session=(Map)ActionContext.getContext.get(“session”);

application=(Map)ActionContext.getContext.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1