struts-config.xml中标签path属性

一、struts-config.xml中标签path属性传多个参数

在struts-config.xml中配置标签时候,通过地址传递参数,想当然的把参数加在后面:

配置信息如下:(这是错误的)




结果提示下列信息:


原先以为不能传递多个参数 ,后来百度了一下。发现是可以的。

解决方法相当的简单:

只需将&符号用&来代替即可:

正确代码如下:



二、服务报异常:java.lang.IllegalArgumentException: Path userLogin.jsp does not start with a 。。。。
struts异常 does not start with a "/" character
2008-10-10 17:43
如果你也遇到以下问题:
java.lang.IllegalArgumentException: Path index.jsp does not start with a "/" character
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1062)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
model.MyActionServlet.process(MyActionServlet.java:22)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


那么,请注意了。你的struts-config.xml文件一定是出错了,就仔细看看 吧!
特别是里面
path="/admin/news"



  ==>input="/logon.jsp">
path="admin/news" ==>path="/admin/news"
==>

有时,不一定是配置文件出的错。看看你的Action中的execute()方法,特别是retrun mapping.findForward("XXXXXXXXXXX"),
我今天就错在这里了,本来的意思是return mapping.findForward("editnews");
可我却写成return new ActionForward("newslist");其实这句也对(如放在删除或者添加后面的 跳转 ),只不过放在这里就不对了,因为我的"editnews"在配置文件里已经定义过别名了

我在这里说一些比较细的地方,都是我遇到过的,其他方面网上书上都说得很详细了。
struts-config.xml文件,这是很重要的地方,成败的关键啊!!
一般的样式就是这样,红色部分要注意














------虽然在Eclipse开发当中,顺序不是这样,但是出问题时可以考虑先改这里的顺序,我试过在这里改了以后问题解决了。
attribute="userLoginForm"
input="/userLogin.jsp"
name="userLoginForm"
path="/userLogin"
scope="request"
type="com.yourcompany.struts.action.UserLoginAction"
validate="false">

-------“/”这个也要注意,我在网上找错的时候,发现有不少也有这个错误Path 文件名字 does not start with a "/" character 记得加“/”这个,很容易就忘记,我是连续忘记了两次,
三、

如在web.xml中这样配置路径
。。。

[color=red]config/module/xtgl[/color]

/WEB-INF/config/struts/struts-xtgl.xml

。。。

注意红色标注,如果我需要从目录module下访问,需要在struts配置文件中这样配置,红色
type="com.crls.mboa.kcgl.module.quotationmanage.action.QuotationManageAction"
parameter="findQuotationInfo">


你可能感兴趣的:(struts-config.xml中标签path属性)