¶ÁÊéÈË

Ϊʲô,Ϊʲô,Ò»¸öССµÄÓйØÎÊÌâÀ§ÈÅ

·¢²¼Ê±¼ä£º 2012-02-15 12:09:44 ×÷Õߣº rapoo

Ϊʲô,Ϊʲô,Ò»¸öССµÄÎÊÌâÀ§ÈÅÁËÎÒÒ»Ìì,Â鷳ǰ±²°ï°ïÎÒ,ÎÒ²»Ïë˵¹òÇó,ÒòΪÎÒÊÇÄÐÈË,ËùÒÔ²»»áÇáÒ×Ϲò
struts ÈëÃż¶....ÏÖÔÚÎÒÏë×öµÄÊÇ£º´Óregedit.jspÒ³ÃæÉÏÊäÈëÓû§ÃûºÍÃÜÂë,Èç¹ûÁ½´ÎÃÜÂëÒ»Ñù,Ôò½øÈë»¶Ó­Ò³Ãæ,Èç¹ûÁ½´ÎÃÜÂë²»Ò»Ñù,Ìáʾ´íÎó,Èç¹ûÓû§ÃûΪ·Çadmin,ÔòÌáʾÓû§Óû§Ãû²»ÄÜΪ·Çadmin,¿ÉÊÇÎÒ×öÁËÒ»ÌìÒ²²»¶Ô,Â鷳ǰ±²Ö¸µãÒ»ÏÂ.
regedit.jspºËÐÄ´úÂ룺
<html:form action= "/regedit ">
pass1 : <html:password property= "pass1 "/> <html:errors property= "pass1 "/> <br/>
pass : <html:password property= "pass "/> <html:errors property= "pass "/> <br/>
name : <html:text property= "name "/> <html:errors property= "name "/> <br/> <html:errors property= "notname "/>
<html:submit value= "azafvgafadfs "/> <html:cancel/> <br>
´íÎóÐÅϢΪ£º <html:errors/>
</html:form>


³É¹¦Ãæok.jspºËÐÄ´úÂ룺
<body>
welcome come! <br>
name: ${use.name }pass:${use.pass }
</body>

regeditActionºËÐÄ´úÂë
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
RegeditForm regeditForm = (RegeditForm) form;// TODO Auto-generated method stub
ActionForward forward =new ActionForward();

ActionMessages message = null;
if(!regeditForm.getName().equalsIgnoreCase( "admin ")){
message=new ActionMessages();
message.add( "notname ", new ActionMessage( "regedit.name.not "));
saveMessages(request, message);
forward= mapping.findForward( "error ");
}else{
request.setAttribute( "use ", regeditForm);
forward= mapping.findForward( "ok ");
}

return forward;
}
struts-config.xml´úÂ룺
<form-beans >
<form-bean name= "regeditForm " type= "com.yourcompany.struts.form.RegeditForm " />

</form-beans>

<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute= "regeditForm "
input= "/regedit.jsp "
name= "regeditForm "
path= "/regedit "
scope= "request "
type= "com.yourcompany.struts.action.RegeditAction " >
<forward name= "success " path= "/ok.jsp " />
<forward name= "error " path= "/error.jsp " />
</action>


</action-mappings>

<message-resources parameter= "com.yourcompany.struts.ApplicationResources " />
error.jspºËÐÄ´úÂë
<body>


This a struts page. <br> <html:errors/>
</body>

¾ÍÕâЩÁË,ллÁË

[½â¾ö°ì·¨]
Ö±½ÓȥѧStruts2°É
Struts1ûStruts2ºÃÓ𡣡
[½â¾ö°ì·¨]
¾ßÌåÄĸöµØ·½²»¶ÔÄØ

[½â¾ö°ì·¨]
ActionForward forward =new ActionForward();


Õâ¾äÊǸÉÂïµÄ°¡¡¢£¿£¿£¿

return mapping.findForward( "success ");
ÕâÑù·µ»Øµ½³É¹¦Ò³°É

¶ÁÊéÈËÍø >Java Web¿ª·¢

ÈȵãÍÆ¼ö