maven开发ssh项目(struts2spring3hibernate3)【第二篇struts2的基本配置】

新建action包(包名看你的情况)

新建class命名时一般为、、功能名+Action

这些类都要extends actionsupport


然后在struts.xml中配置该action的映射

其中action标签中的name为映射名,class是映射类,method是要执行的方法(如果没有指定method那就默认执行映射类中覆盖其父类的execute方法)


通配符配置法:

<constant name="struts.enable.DynamicMethodInvocation" value="true" />这个必须写

 <action name="LoginAction_*" class="LoginAction" method="{1}">
<result name="success">/Login.jsp</result>
</action>
<action name="*_*" class="com.ppx.{1}" method="{2}">
<result name="success">/Login.jsp</result> //第一个星号代表{1}

</action>

如果只是单纯使用struts的话就忽略下面的东西吧上面就够了

因为在上一篇已经说了业务层都交给spring去管理

所以在action中要调用业务层只需要在配置文件application.xml中注入业务

然后在action去set就行




猜你喜欢

转载自blog.csdn.net/qq_34299694/article/details/81006525