<quote>
<pre>点击一个链接“添加用户”始终无法转到正确的页面,出的是404错误。。请大家看看问题在哪,虽然多,但很简单,配置应该没问题,是链接的问题吧?请看看,谢谢!这个是index.jsp <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><html>
<head>
<base href="<%=basePath%>">
<title>index</title>
</head>
<body>
<a href="user/user!add?name=a">添加用户</a>
</body>
</html>
==================================================================================================
这个是struts.xml:
<constant name="struts.devMode" value="true" />
<package name="user" namespace="/user" extends="struts-default">
<action name="user" class="com.XC.yangjian.action.UserAction" >
<result >
/user_add_success.jsp
</result>
<result name="error">
/user_add_error.jsp
</result>
</action>
</package>
==============================================================================================
这个是我的JavaBean:
package com.XC.yangjian.action;import com.opensymphony.xwork2.ActionSupport;public class UserAction extends ActionSupport {
private String name;
public String add() {
if(name == null || !name.equals("admin")) {
this.addFieldError("name", "name is error");
return ERROR;
}
return SUCCESS;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
================================================================================================
web.xml就是默认的:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>两个jsp页面不用贴出来了,因为根本没跳转过去。在线等</pre>
</quote>
<pre>点击一个链接“添加用户”始终无法转到正确的页面,出的是404错误。。请大家看看问题在哪,虽然多,但很简单,配置应该没问题,是链接的问题吧?请看看,谢谢!这个是index.jsp <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><html>
<head>
<base href="<%=basePath%>">
<title>index</title>
</head>
<body>
<a href="user/user!add?name=a">添加用户</a>
</body>
</html>
==================================================================================================
这个是struts.xml:
<constant name="struts.devMode" value="true" />
<package name="user" namespace="/user" extends="struts-default">
<action name="user" class="com.XC.yangjian.action.UserAction" >
<result >
/user_add_success.jsp
</result>
<result name="error">
/user_add_error.jsp
</result>
</action>
</package>
==============================================================================================
这个是我的JavaBean:
package com.XC.yangjian.action;import com.opensymphony.xwork2.ActionSupport;public class UserAction extends ActionSupport {
private String name;
public String add() {
if(name == null || !name.equals("admin")) {
this.addFieldError("name", "name is error");
return ERROR;
}
return SUCCESS;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
================================================================================================
web.xml就是默认的:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>两个jsp页面不用贴出来了,因为根本没跳转过去。在线等</pre>
</quote>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货