当前位置:编程学习 > JAVA >>

struts.xml配置问题

<!-- 指定国际化配置文件 -->
<constant name="struts.custom.i18n.resources" value="validationMessages"/>
<constant name="struts.locale" value="zh_CN"/>
<constant name="struts.i18n.encoding" value="UTF-8"/>

    <include file="struts-default.xml"/>
    <package name="amigo" extends="struts-default">
     <!-- 配置用户管理的Action -->
     <action name="*UserAction"  class="userAction" method="{1}">
            <result name="list">/user/userList.jsp</result>
            <result name="update">/user/updateUser.jsp</result>
            <result name="main">/user/main.jsp</result>
            <result name="login">/user/login.jsp</result>
            <result name="success">/success.jsp</result>
            <result name="error">/error.jsp</result>
        </action>
        
        <!-- 备忘类型管理的Action -->
        <action name="*MemoTypeAction"  class="memoTypeAction" method="{1}">
            <result name="list">/memotype/memoTypeList.jsp</result>
            <result name="update">/memotype/updateMemoType.jsp</result>
            <result name="login">/user/login.jsp</result>
        </action>
        
        <!-- 备忘信息管理的Action -->
        <action name="*MemoAction"  class="memoAction" method="{1}">
            <result name="list">/memo/memoList.jsp</result>
            <result name="listRemind">/memo/remindMemoList.jsp</result>
            <result name="update">/memo/updateMemo.jsp</result>
            <result name="save">/memo/addMemo.jsp</result>
            <result name="login">/user/login.jsp</result>
        </action>
    </package>
</struts>    不知道访问怎么访问,这是做的一个备忘录模块 --------------------编程问答-------------------- 这个是基础哦:
访问路径一般是
应用路径+package域名空间+action映射路径。
例:如果你的项目路径是/note
包的域名空间是amigo
action的路径是配置中的name,name中的* 要用方法名去替换。
那么 这些action的访问路径分别为
http://localhost:8080/note/amigo/方法名UserAction.do
http://localhost:8080/note/amigo/方法名MemoTypeAction.do
http://localhost:8080/note/amigo/方法名MemoAction.do --------------------编程问答--------------------
引用 1 楼 beijing20110905 的回复:
这个是基础哦:
访问路径一般是
应用路径+package域名空间+action映射路径。
例:如果你的项目路径是/note
包的域名空间是amigo
action的路径是配置中的name,name中的* 要用方法名去替换。
那么 这些action的访问路径分别为
http://localhost:8080/note/amigo/方法名UserAction.do
http://localhost:8080/note/amigo/方法名MemoTypeAction.do
http://localhost:8080/note/amigo/方法名MemoAction.do




我刚才访问了,访问地址是:http://127.0.0.1:8080/memorial/com/action/user/UserAction直接跳到success.jsp,如果我要访问登录界面怎么访问啊,求访问地址 --------------------编程问答--------------------
引用 2 楼 u010549302 的回复:
Quote: 引用 1 楼 beijing20110905 的回复:

这个是基础哦:
访问路径一般是
应用路径+package域名空间+action映射路径。
例:如果你的项目路径是/note
包的域名空间是amigo
action的路径是配置中的name,name中的* 要用方法名去替换。
那么 这些action的访问路径分别为
http://localhost:8080/note/amigo/方法名UserAction.do
http://localhost:8080/note/amigo/方法名MemoTypeAction.do
http://localhost:8080/note/amigo/方法名MemoAction.do




我刚才访问了,访问地址是:http://127.0.0.1:8080/memorial/com/action/user/UserAction直接跳到success.jsp,如果我要访问登录界面怎么访问啊,求访问地址

你确定你的访问路径是对的?
直接在UserAction前面加登录的方法名。
例子:http://127.0.0.1:8080/memorial/com/action/user/loginUserAction --------------------编程问答-------------------- 其实就是访问返回结果为return "login";的那个action方法。 --------------------编程问答--------------------
引用 4 楼 beijing20110905 的回复:
其实就是访问返回结果为return "login";的那个action方法。



访问不了啊,报空指针错误,你有时间不?加我扣扣,远程帮帮我,急啊 --------------------编程问答--------------------
引用 5 楼 u010549302 的回复:
Quote: 引用 4 楼 beijing20110905 的回复:

其实就是访问返回结果为return "login";的那个action方法。



访问不了啊,报空指针错误,你有时间不?加我扣扣,远程帮帮我,急啊

不帮。上班呢。找个 struts的文档好好研究下。就会了。我的第一条回复已经把路径问题讲的很清楚了。
空指针,这个你要处理异常。看下错误信息,哪一行报错,然后加非空判断就行。
这些问题,直接复制错误信息百度一下,就有答案了。 --------------------编程问答-------------------- 还是不能访问啊,忙不?可以加你扣扣不? --------------------编程问答-------------------- 现在web.xml把拦截器配置一下,访问action的时候,就是直接访问'别名.action'就行了  --------------------编程问答--------------------
引用 8 楼 mwygeeqgeeqg 的回复:
现在web.xml把拦截器配置一下,访问action的时候,就是直接访问'别名.action'就行了 




我试试看啊
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,