|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
用java开发web只要两本书:一本是关于java基础的,一本是关于jsp、servlet的就可以了。开发周期长,我就来讲句题外话,现在有很多思想都是通过java来展现。办理|成绩|反复|反复提交Insert.jsp代码以下:<%@pagecontentType="text/html;charset=UTF-8"language="java"%><%@tagliburi="/WEB-INF/struts-bean.tld"prefix="bean"%><%@tagliburi="/WEB-INF/struts-html.tld"prefix="html"%><%@tagliburi="/WEB-INF/struts-logic.tld"prefix="logic"%><html:htmllocale="true"><head><html:base/><title>insert.jsp</title></head><body><html:formaction="insert"method="post"><bean:messagekey="label.name"/><html:textproperty="name"/><bean:messagekey="label.phone"/><html:textproperty="phone"/><bean:messagekey="label.address"/><html:textproperty="address"/><html:submit><bean:messagekey="modify.add"/></html:submit><html:reset><bean:messagekey="button.reset"/></html:reset></html:form><html:errors/></body></html:html>PrepareInsertAction代码以下:publicclassPrepareInsertActionextendsAction{publicActionForwardexecute(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse){System.out.print("helloPrepareInsertAction");//创立一个新的令牌saveToken(request);returnmapping.findForward("inserttoken");}}InsertAction代码以下:publicclassInsertActionextendsAction{publicActionForwardexecute(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse)throwsException{ModifyFormmodifyForm=(ModifyForm)form;//失掉tokenStringtoken_request=request.getParameter("org.apache.struts.taglib.html.TOKEN");//打出来看看是甚么东东System.out.println("tokeninrequestis:"+token_request);ActionErrorserrors=newActionErrors();//判别token是不是无效,假如为假证实有反复提交,声明一个毛病信息,并反应出来if(!isTokenValid(request)){errors.add("insettoken",newActionError("error.invalid.token"));saveErrors(request,errors);saveToken(request);return(newActionForward(mapping.getInput()));}//当用户初次提交时返!isTokenValid()前往trueelse{resetToken(request);}intresult=newListBean().add(modifyForm);if(result==1){returnmapping.findForward("addlist");}else{returnmapping.findForward("error");}}}ModifyForm代码以下:publicclassModifyFormextendsActionForm{publicvoidreset(ActionMappingmapping,HttpServletRequestrequest){this.address=null;this.name=null;this.phone=null;}publicStringgetPhone(){returnphone;}publicvoidsetPhone(Stringphone){this.phone=phone;}publicStringgetAddress(){returnaddress;}publicvoidsetAddress(Stringaddress){this.address=address;}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}publicStringgetId(){returnid;}publicvoidsetId(Stringid){this.id=id;}}Struts-config.xml设置以下:<struts-config><data-sources/><form-beans><form-beanname="modifyForm"type="com.lyx.struts.form.ModifyForm"/></form-beans><global-exceptions/><global-forwards><forwardname="inserttoken"path="/tokeninsert.jsp"/></global-forwards><action-mappings><!--拔出纪录时token查验第一个跳的action--><actionpath="/prepareInsert"type="com.lyx.struts.action.PrepareInsertAction"/><!--拔出纪录时token查验后的第二个action--><actionattribute="modifyForm"input="/tokeninsert.jsp"name="modifyForm"path="/insert"scope="request"type="com.lyx.struts.action.InsertAction"/></action-mappings><message-resourcesparameter="com.lyx.struts.ApplicationResources"/></struts-config>Applicationresources.properties设置以下:error.invalid.token=repeatsubmitlabel.user=usernamelable.phone=phonelabel.address=addressmodify.add=addlabel.tokeninsert=tokeninsertbutton.reset=reset
关于第二点:俺问问你,如果是企业级项目的话,诸如RMI,EJB,等一些关键技术,这些难道都不需要学么?如果光是使用jsp,servlet,javabean的话。 |
|