日期:2014-05-17  浏览次数:20810 次

SSH2中的No result defined for action的问题。。。
网站运行的时候报下面的错误 
HTTP Status 404 - No result defined for action com.zjj.action.Login and result pe

type Status report

message No result defined for action com.zjj.action.Login and result pe

description The requested resource (No result defined for action com.zjj.action.Login and result pe) is not available.


web.xml的文件内容
XML code

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  <display-name></display-name>    
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
  <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
          org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
      </filter-class>
  </filter>
  <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
  </filter-mapping></web-app>





struts.xml文件内容
XML code

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
    <package name="default" extends="struts-default">
        <!-- 配置名为 login的action -->
        <action name="login" class="login">
                        <result name="pe">/pe.jsp</result>
            <result name="success">/success.jsp</result>
        </action>
    </package>
</struts>    





Login.java文件内容
Java code

package com.zjj.action;

import com.opensymphony.xwork2.ActionSupport;
import com.zjj.service.AdminService;

public class Login extends ActionSupport {
    /**
     * 
     */
    private static final long serialVersionUID = 1459299920038614538L;
    private AdminService adminService;
    private Integer adminId;
    private String name;
    private String password;

    public AdminService getAdminService() {
        return adminService;
    }

    public void setAdminService(AdminService adminService) {
        this.adminService = adminService;
    }

    public Integer getAdminId() {
        return adminId;
    }

    public void setAdminId(Integer adminId) {
        this.adminId = adminId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    public String execute() throws Exception {
        if(name.equals("zjj")){
            if(password.equals("123")){
                return "success";