点击一个链接“添加用户”始终无法转到正确的页面,出的是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页面不用贴出来了,因为根本没跳转过去。在线等
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页面不用贴出来了,因为根本没跳转过去。在线等
解决方案 »
- java 保存ftp上的xml文件
- hibernate无法建表,求解
- 动态生成hibernate配置文件hbm.xml文件,并导入项目使用
- Struts2标签问题
- webLogic与Jboss的端口号怎么修改???
- 可不可以在一个已经写好但没有加任何框架的项目中,加入新的模块,使用框架??
- 100分求助:hibernate操作Oracle的时候主键的问题.
- exception setting property value with CGLIB
- 如何将一个已有的外部私钥(PEM格式)导入到.keystore,或者反过来
- Struts中怎样在一个jsp页面中传递一个对象给formBean啊?
- java实现分步骤录入功能
- 求毕业设计+论文(基于jsp、java的BBS论坛的设计与实现)
这样试一下