admin/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>My JSP 'login.jsp' starting page</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">
--> </head>
<body>
<s:form name="form1" method="post" action="admin/adminlogin.action" theme="simple">
<table cellpadding="0" cellspacing="0" align="center" width="50%">
<tr><th align="center">管理员登陆</th></tr>
<tr><td>用户名:</td><td>
<s:textfield name="username" label="用户名" size="20"></s:textfield></td></tr>
<tr><td>密码:</td><td><s:password name="password" label="密码" value="" size="20"></s:password></td></tr>
<tr><td></td><td align="left"><s:submit value="提交"></s:submit> <s:reset value="重置"></s:reset></td></tr>
</table> </s:form>
<br/>
<hr/>
<form action="admin/adminlogin.action" method="post">
<table align="center" border=1 width="300" bgcolor=#F5FFE1>
<tr><td colspan="2" align="center" width="250" bgcolor="#CCCCFF">用户登录界面</td></tr>
<tr><td width="50">姓名:</td><td><input type="text" name="username"/></td></tr>
<tr><td width="50">密码:</td><td><input type="password" name="password" size=22/></td></tr>
<tr><td align="center" colspan=2><input type="submit" value="登录"/><input type="reset" value="重置" /></td></tr>
</table>
</form>
</body>
</html>
为什么下面一个可以登录,而上面一个使用s:form标签却不行,报错:(1291750 ms) [http-8080-3] WARN : org.apache.struts2.components.ServletUrlRenderer#warn : No configuration found for the specified action: 'admin/adminlogin.action' in namespace: '/admin'. Form action defaulting to 'action' attribute's literal value.
struts.xml文件里:<package name="admin" extends="struts-default" namespace="/admin">
<action name="adminlogin" class="loginAction" method="adminlogin">
<result name="success">/admin/index.jsp</result>
<result name="error">/fail.jsp</result>
<result name="input">/index.jsp</result>
</action>
</package>
<%@ 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>My JSP 'login.jsp' starting page</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">
--> </head>
<body>
<s:form name="form1" method="post" action="admin/adminlogin.action" theme="simple">
<table cellpadding="0" cellspacing="0" align="center" width="50%">
<tr><th align="center">管理员登陆</th></tr>
<tr><td>用户名:</td><td>
<s:textfield name="username" label="用户名" size="20"></s:textfield></td></tr>
<tr><td>密码:</td><td><s:password name="password" label="密码" value="" size="20"></s:password></td></tr>
<tr><td></td><td align="left"><s:submit value="提交"></s:submit> <s:reset value="重置"></s:reset></td></tr>
</table> </s:form>
<br/>
<hr/>
<form action="admin/adminlogin.action" method="post">
<table align="center" border=1 width="300" bgcolor=#F5FFE1>
<tr><td colspan="2" align="center" width="250" bgcolor="#CCCCFF">用户登录界面</td></tr>
<tr><td width="50">姓名:</td><td><input type="text" name="username"/></td></tr>
<tr><td width="50">密码:</td><td><input type="password" name="password" size=22/></td></tr>
<tr><td align="center" colspan=2><input type="submit" value="登录"/><input type="reset" value="重置" /></td></tr>
</table>
</form>
</body>
</html>
为什么下面一个可以登录,而上面一个使用s:form标签却不行,报错:(1291750 ms) [http-8080-3] WARN : org.apache.struts2.components.ServletUrlRenderer#warn : No configuration found for the specified action: 'admin/adminlogin.action' in namespace: '/admin'. Form action defaulting to 'action' attribute's literal value.
struts.xml文件里:<package name="admin" extends="struts-default" namespace="/admin">
<action name="adminlogin" class="loginAction" method="adminlogin">
<result name="success">/admin/index.jsp</result>
<result name="error">/fail.jsp</result>
<result name="input">/index.jsp</result>
</action>
</package>
那样如果你的扩展名改了呢.?那不是页面要改.?
<s:form namespace="/admin" action="adminlogin"> 这个地方的action只需要填写与你struts.xml里面那个action的name一致就可以. 这样写的好处是你以后的扩展名随便换,页面上的提交路径都不用再改了.!