Struts2在行动中返回无法找到另一个类文件

时间:2016-09-23 19:28:20

标签: struts2

 public class Login extends ActionSupport {

     //connection made  

     PreparedStatement pstmt = con.prepareStatement("select * from register1 where username=? and password=?");
     pstmt.setString(1, username);
     pstmt.setString(2, pwd);

     ResultSet rs = pstmt.executeQuery();    

     if (rs.next()) {
         String role = rs.getString(3);
         if (role == null || role.equals("user")) {    
             session.setAttribute("username", username);
             return "Cart"; //here i want to go for another .java file
         }   
     }

struts.xml中

<action name="Login" class="mypack.Login">
<result name="Cart" type="dispatcher">
        <param name="location">mypack.CartSelect</param>//Another .java file which support Action Support 
        </result>
</action>

第3课:

public class CartSelect extends ActionSupport implements ServletContextAware {

public String execute() throws Exception {

1 个答案:

答案 0 :(得分:1)

我认为您需要的不是调度员,而是重定向。

Here是重定向操作结果类型的参考。