| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 649 人关注过本帖
标题:Struts问题
只看楼主 加入收藏
jay_sandra
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-3-27
收藏
 问题点数:0 回复次数:4 
Struts问题

我用JBuilderX编写Struts 程序,编写一个简单的登陆程序,运行时抱错 如下:
type Status report
message No Context configured to process this request
description The server encountered an internal error (No Context configured to process this request) that prevented it from fulfilling this request.

TomCat 报错:StandardHost[localhost]: MAPPING configuration error for request URI

请问是什么原因?我觉得程序都写对了以下是我的程序
index.jsp登陆页面:
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
login
</title>
</head>
<body bgcolor="#ffffff">
<form action="/loginAction.do">
<p align="center">
UserName:<input type="text" name="username" value=""/><br />
UserPass:<input type="password" name="userpass" value=""/><br />
<input type="submit" name="sub" value="提交"/>
<input type="reset" name="res" value="取消"/>
</p>
</form>
</body>
</html>


然后我建立一个ActionForm名为UserForm,以下是程序:
package strutspro;

import org.apache.struts.action.*;
import org.apache.struts.action.ActionForm;

public class UserForm extends ActionForm {
private String username;
private String userpass;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserpass() {
return userpass;
}
public void setUserpass(String userpass) {
this.userpass = userpass;
}
}

然后建立一个ActionForm名为loginAction:
package strutspro;

import org.apache.struts.action.*;
import javax.servlet.http.*;

public class LoginAction extends Action
{
public ActionForward perform(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
{
UserForm userForm = (UserForm) actionForm;
String loginname = userForm.getUsername();
String loginpass = userForm.getUserpass();

boolean res = (loginname.equals("jay") && loginpass.equals("123456"));
if(res)
{
return actionMapping.findForward("loginOk");
}
else
{
return actionMapping.findForward("loginNo");
}
}
}

struts-config.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
<struts-config>
<form-beans>
<form-bean name="userForm" type="strutspro.UserForm" />
</form-beans>
<action-mappings>
<action name="userForm" path="/loginAction" scope="request" type="strutspro.LoginAction">
<forward name="loginOk" path="/welcome.jsp" />
<forward name="loginNo" path="/error.jsp" />
</action>
</action-mappings>
</struts-config>

web.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>defaultroot</display-name>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
</web-app>

谢谢大家帮忙看看吧~!!小弟万分感谢~~~~~~~

搜索更多相关主题的帖子: Struts 
2006-03-27 14:43
jay_sandra
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-3-27
收藏
得分:0 
自己顶~大家快来帮帮我啊~~~
2006-03-27 14:46
hotleave
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-4-4
收藏
得分:0 

也是初学者,感觉你应该在struts-config.xml里设置对"loginAction.do“的映射。

2006-04-04 20:52
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 
我向来喜欢用netbeans~为什么?因为他集成了struts1.2.7

淘宝杜琨
2006-04-04 21:47
hotleave
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-4-4
收藏
得分:0 
还有你没有建立Action类。这是根本原因。
2006-04-05 17:39
快速回复:Struts问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041101 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved