首页 > 学院 > 开发设计 > 正文

Struts中访问通配符

2019-11-06 07:59:39
字体:
来源:转载
供稿:网友

使用通配符优化访问步骤:

如:

<action name="hello" class="cn.lfsenior.Hello.HelloStruts2" method="login">    <result name="login">/success.jsp</result></action> <action name="hello" class="cn.lfsenior.Hello.HelloStruts2" method="register">    <result name="register">/register.jsp</result></action>

 

通过使用通配符改为:

1、

<action name="hello_*" class="cn.lfsenior.Hello.HelloStruts2" method="{1}">    <result name="login">/index.jsp</result>    <result name="register">/register.jsp</result></action>

2、

 <!-- http://localhost:8080/struts02/user_login -->//星号表示的就是login <action name="user_*" class="cn.itcast.a_config.UserAction" method="{1}"><result name="{1}">/{1}.jsp</result></action>

解析:{1}表示name中第一个*号代表的内容,如果有两个*如:hello_*_*则{2}表示第二个星号的内容。

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表