我用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问题