请帮忙说明下这个struts配置文件!谢谢谢谢!万分感谢!

woshibabyde 2010-11-08 05:10:15
<?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>
<constant name="struts.action.extension" value="action" />
<constant name="struts.ognl.allowStaticMethodAccess" value="true" />
<include file="liuyang.xml"></include>
<package name="comm" extends="struts-default" >
<global-results>
<result name="wrong">/error.jsp</result>
</global-results>
</package>

<package name="front.atsx" namespace="/atsx" extends="struts-default">
<action name="*" method="{1}" class="front.atsXAct">
<result name="index" type="freemarker">/index.html</result>
<result name="high" type="freemarker">/luotuo.html</result>
<result name="success" type="freemarker">${pageUrl}</result>
</action>
</package>

</struts>



配置成这样 该通过什么路径访问这个action呢?package标签里的name namespace属性都是什么含义啊
最重要的是action标签里的name为什么是*呢?methot{1}是什么意思啊?
还有如果我要使用多个action的话 如何在这个配置文件上修改,达到目的呢?请不吝赐教!小弟这里谢谢了!
...全文
86 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
huangli21 2010-11-08
  • 打赏
  • 举报
回复
struts学习中……
qiluchao1016 2010-11-08
  • 打赏
  • 举报
回复
6楼讲的ok
  • 打赏
  • 举报
回复
6楼讲的不错
jump0907 2010-11-08
  • 打赏
  • 举报
回复
我也来学习下,刚好正在上struts
shanxmxj 2010-11-08
  • 打赏
  • 举报
回复
形式一:调用相同Action中的不同方法

<action name="*Action" class="Jcuckoo.LoginRegistAction" method="{1}">
<result name="input">/login.jsp</result>
<result name="error">/error.jsp</result>
<result name="success">/welcome.jsp</result>
</action>
其中表达式{1}的值name属性值中第一个*的值。
如果用户请求的URL为loginAction.action,则调用Jcuckoo.LoginRegistAction中的login方法;
如果用户请求的URL为registerAction.action,则调用Jcuckoo.LoginRegistAction中的register方法;

形式二:通过匹配,调用不同的Action的execute方法


<action name="*Action" class="Jcuckoo.{1}Action">
<result name="input">/login.jsp</result>
<result name="error">/error.jsp</result>
<result name="success">/welcome.jsp</result>
</action>
上面没有出现method属性,故默认调用对应的execute方法
如果用户请求的URL为LoginAction.action,则调用Jcuckoo.LoginAction中的execute方法;
如果用户请求的URL为RegisterAction.action,则调用Jcuckoo.RegisterAction中的execute方法;

形式三:动态结果

<action name="crud_*" class="Jcuckoo.CrudAction" method="{1}">
<result name="input">/input.jsp</result>
<result>/{1}.jsp</result>
</action>
当处理结果是input时,会转到/input.jsp页面
当处理结果是success时,
如果crud_create.action,则会执行Jcuckoo.CrudAction中的create方法,并且跳转到/create.jsp;
如果crud_delete.action,则会执行Jcuckoo.CrudAction中的delete方法,并且跳转到/delete.jsp;
shanxmxj 2010-11-08
  • 打赏
  • 举报
回复
[Quote=引用楼主 woshibabyde 的回复:]
<?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>
<c……
[/Quote]
package里的name ,namespace 是包名 和包的命名空间 是用来却确定你是要访问的哪个包下的action。
action=“*” 这个是通配符
method={1} 是用来调用方法的。

十橙心橙意 2010-11-08
  • 打赏
  • 举报
回复
http://wenku.baidu.com/view/49ac1c1cfad6195f312ba65e.html

自己下载吧!!
woshibabyde 2010-11-08
  • 打赏
  • 举报
回复
啥书啊 请推荐。。这个写法我没见过 小弟初学乍练的
十橙心橙意 2010-11-08
  • 打赏
  • 举报
回复
强烈要求你看书!

这样的概念一般很表达完整!
十橙心橙意 2010-11-08
  • 打赏
  • 举报
回复
哎!顶顶你吧!

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧