使用通配符优化访问步骤:
如:
<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}表示第二个星号的内容。
新闻热点
疑难解答