关于Struts2的配置,求指点。谢谢

There is no Action mapped for namespace / and action name user_login.
初学框架,不知道哪里写错了。求指点!

图片说明

login.jsp

 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s"  uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

    <title>用户登录</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <s:head/>
  </head>

  <body>
    <center>
        <h1>用户登录</h1>
        <!-- <s:a action="user_addUI" namespace="/user">添加新用户</s:a> -->
        <s:form action="user_login" namespae="/user" method="post">
            <s:textfield label="用户名" name="user.username"></s:textfield>
            <s:password label="密码" name="user.password"></s:password>
            <s:submit value="登录"></s:submit>
        </s:form>
    </center>
  </body>
</html>

userList.jsp

 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s"  uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <title>用户列表</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">   

  </head>

  <body>
    <center>
        <h2>用户列表</h2>
        <!-- <h3><s:a action="user_addUI" namespace="/">添加新用户</s:a> </h3> -->
        <table width="90%" border="1">
            <tr>
                <th>用户id</th>
                <th>用户名称</th>
                <th>用户密码</th>
                <th>操作</th>
            </tr>
            <s:iterator  value="userList">
                <tr>
                    <td><s:property value="id"/> </td>
                    <td><s:property value="username"/> </td>
                    <td><s:property value="password"/> </td>
                    <%-- <td><s:a action="user_updateUI" namespace="/user"><s:param name="user.id">${id}</s:param>修改</s:a>
                    &nbsp;&nbsp;<s:a action="user_delete" namespace="/user"><s:param name="user.id">${id}</s:param>删除</s:a></td> --%>
                </tr>
            </s:iterator>
        </table>
    </center>
  </body>
</html>

Struts.xml

 <?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>    
     <constant name="struts.i18n.encoding" value="UTF-8"/>
    <constant name="struts.configuration.xmlreload" value="true"/>
    <constant name="struts.devMode" value="true"/>
    <constant name="struts.ui.theme" value="xhtml"/>

    <package name="user" namespace="/user" extends="struts-default">
        <action name="user_*" class="com.chen.action.UserAction" method="{1}">
            <result name="success" type="redirectAction">user_queryInfo.action</result>
            <result name="input">/index.jsp</result>
            <result name="userList">/userList.jsp</result>
        </action>
    </package>
</struts>    

UserAction

 package com.chen.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.chen.entity.User;
import com.chen.service.UserService;
import com.opensymphony.xwork2.ActionSupport;
@Controller
@Scope("prototype")
public class UserAction extends ActionSupport{
    @Autowired
    private UserService userService;
    private User user;
    private List<User> userList;
    public String execute() throws Exception {
        return null;
    }
    public String login() {
        if (user != null) {
            User user2 = userService.login(user);
            if (user2 != null) {
                return SUCCESS;
            }
        }
        this.addFieldError("user.username", "用户名或密码错误!");
        return INPUT;
    }

    public String queryInfo() {
        userList = userService.queryInfo(user);
        return "userList";
    }

}

struts.xml的配置有没有配置,可以贴出来看下,这种错误一般是配置有问题引起的



/online/datashow/list.jsp
/online/datashow/listlog.jsp

"/user" 改成 "/"



user_queryInfo.action
/index.jsp
/userList.jsp

如果userAction是用spring管理的话,是不用带路径的
可以把@Controller改成@Controller("userAction")


根据 Struts.xml中的配置
login.jsp中的

应该改为

根据 配置 后缀应该是 xhtml
user_login改成 user_login.xhtml