struts2动态结果集不能用

J2EE 码拜 9年前 (2015-04-12) 977次浏览 0个评论

主要有三个文件!
这是我连接的文件index.jsp!

  <body>
       Result</br>
       <a href="struts/user?type=1">动态结果集</a></br>
 <br>
  </body>

struts.xml的配置如下

   <constant name="struts.devMode" value="true" />
     
     
    <package name="user" namespace="/struts" extends="struts-default">

        <action name="user" class="actionClass.User">
            <result>
                ${pages}
            </result>
        </action>
  
        
    </package>

一下是User.java

package actionClass;

import com.opensymphony.xwork2.ActionSupport;

public class User extends ActionSupport{

	private String pages;
	private int type;

	public String getPage() {
		return pages;
	}

	public void setPage(String page) {
		this.pages = page;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String execute() throws Exception {
		if ( type == 1 ) {
        	pages = "/Success.jsp";
        } else {
        	pages = "/error.jsp";
        }
        System.out.println(pages);
		return SUCCESS;
	}


}

就是这么多了!但是我点击链接,页面就显示404,我哪里配置错了?并且在myeclipse中提示struuts.xml的<result>一行有错误。求助各位大神。

struts2动态结果集不能用
40分
一般的方法:

先确定正确的url是什么,假如是:http://192.168.0.1:8080/project/struts/user?type=1

然后需要确定 <a href=”struts/user?type=1″>动态结果集</a></br>,这个最终形成的url是多少。
假设形成的url是:http://192.168.0.1:8080/projectstruts/user?type=1,project和struts中间差个/,那么就要修改<a href=”struts/user?type=1″>来调整。

struts2动态结果集不能用
web.xml文件是不是放到lib文件夹里去了?放WEB-INF文件夹下

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明struts2动态结果集不能用
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!