日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

struts中多个模块时,使用多个struts-config.xml文件之间时如何切换的!

發(fā)布時(shí)間:2023/12/2 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 struts中多个模块时,使用多个struts-config.xml文件之间时如何切换的! 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.配置web.xml文件,通知控制器:
<!-----------------這個(gè)是默認(rèn)的-------------------------->
??? <init-param>
????? <param-name>config</param-name>
????? <param-value>/WEB-INF/struts-config.xml</param-value>
??? </init-param>
<!-----------------這個(gè)是添加模塊的-------------------------->

??? <init-param>
????? <param-name>config/Add</param-name>
????? <param-value>/WEB-INF/struts-config_Add.xml</param-value>
??? </init-param>
<!-----------------這個(gè)是刪除模塊的-------------------------->

??? <init-param>
????? <param-name>config/Del</param-name>
????? <param-value>/WEB-INF/struts-config_Del.xml</param-value>
??? </init-param>
注釋:Del和Add是模塊的名字

2.配置每個(gè)struts-config.xml文件
a)struts-config.xml

<struts-config>
? <data-sources />
? <form-beans>
? <form-bean name="login" type="org.apache.struts.validator.DynaValidatorForm">
? </form-bean>
? </form-beans>
? <global-exceptions />
? <global-forwards />
? <action-mappings>
?
?<action path="/login"
?type="del.Login"?
?name="login"????
?scope="request">????
?<forward name="success" contextRelative="true" path="/login.jsp"/>
?</action>
?
?</action-mappings>
?
</struts-config>

b)struts-config_Add.xml文件
<struts-config>
? <data-sources />
? <form-beans>
? <form-bean name="add" type="org.apache.struts.validator.DynaValidatorForm">
? </form-bean>
? </form-beans>
? <global-exceptions />
? <global-forwards />
? <action-mappings>
?
?<action path="/Add/A"
?type="del.Add"?
?name="add"????
?scope="request">????
?<forward name="success" contextRelative="true" path="/Add/A.jsp"/>
?</action>
?
? </action-mappings>
b)struts-config_Del.xml文件
<struts-config>
? <data-sources />
? <form-beans>
???
???? <form-bean name="del" type="org.apache.struts.validator.DynaValidatorForm">
????? </form-bean>
?????
? </form-beans>
?<global-exceptions />
? <global-forwards/>
? <action-mappings>
?
?<action path="/Del/D"
?type="del.Del"?
?name="del"????
?scope="request">????
?<forward name="success" contextRelative="true" path="/D.jsp"/>
?</action>?
?</action-mappings>
? </struts-config>
</struts-config>
3.測(cè)試
描述:我現(xiàn)在的Del模塊下的MyJsp.jsp文件李想做如下操作:
a).本模塊之間的跳轉(zhuǎn),跳到到D.jsp
代碼如下:
MyJsp.jsp:
<form action="/Del/D.do">
??????????
??????????? <table>
???????????? <tr>
??????????????? <td >
???????????????? 這是del-->del本模塊之間跳轉(zhuǎn):<button type="submit"? on="image/active_login.png" off="image/inactive_login.png"></button>
?????????????????
??????????????? </td>
????????????? </tr>
??????????? </table>
??? </form>
del.Del.java:
public ActionForward execute(ActionMapping arg0, ActionForm arg1, HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
??// TODO Auto-generated method stub
??return arg0.findForward("success");
??
?}
b)不同模塊之間跳轉(zhuǎn)Del--->Add,跳到:Add/A.jsp
MyJsp.jsp:
<form action="/Add/A.do">
??????????
??????????? <table>
???????????? <tr>
??????????????? <td >
???????????????? 這是del--->add不同模塊之間跳轉(zhuǎn):<button type="submit"? on="image/active_login.png" off="image/inactive_login.png"></button>
?????????????????
??????????????? </td>
????????????? </tr>
??????????? </table>
??? </form>
Add.java

public ActionForward execute(ActionMapping arg0, ActionForm arg1, HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
??// TODO Auto-generated method stub
??return arg0.findForward("success");
?}
c)跳轉(zhuǎn)到默認(rèn),如果你已經(jīng)處在其他模塊,需要轉(zhuǎn)回到缺省模塊
MyJsp.jsp
<form action="/login.do">
??????????
??????????? <table>
???????????? <tr>
??????????????? <td >
???????????????? 這是del--->login默認(rèn)模塊之間跳轉(zhuǎn):<button type="submit"? on="image/active_login.png" off="image/inactive_login.png"></button>
?????????????????
??????????????? </td>
????????????? </tr>
??????????? </table>
??? </form>

Login.java

public ActionForward execute(ActionMapping arg0, ActionForm arg1, HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
??// TODO Auto-generated method stub
??return arg0.findForward("success");
?}
4.結(jié)果:出現(xiàn)404錯(cuò)誤,如下:
The requested resource (/Del/D.do) is not available等,請(qǐng)教高手啊!

轉(zhuǎn)載于:https://www.cnblogs.com/yansheng9988/archive/2008/01/27/1055136.html

總結(jié)

以上是生活随笔為你收集整理的struts中多个模块时,使用多个struts-config.xml文件之间时如何切换的!的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。