使用struts2注解方式,访问方法时,怎么使用通配符
1个回答
2016-12-17
展开全部
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="employee" extends="struts-default" namespace="/control/employee">
<action name="add" class="blog.action.HelloWorld" method="execute" >
<result name="success">/WEB-INF/page/addEmployee.jsp</result>
<result name="message">/WEB-INF/page/message.jsp</result>
</action>
<action name="operation_*" class="blog.action.HelloWorld" method="{1}" >
<result name="success">/WEB-INF/page/addEmployee.jsp</result>
<result name="message">/WEB-INF/page/message.jsp</result>
</action>
</package>
</struts>
HelloWorld.java类中有两个方法:execute()和add()
则通过动态方法访问的方式为:
http://localhost:8080/struts2/control/employee/add!execute
和
http://localhost:8080/struts2/control/employee/add!add
通过通配符的方式访问为:
http://localhost:8080/struts2/control/employee/operation_execute
和
http://localhost:8080/struts2/control/employee/operation_add
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询