- This topic has 1 reply, 2 voices, and was last updated 20 years ago by Riyad Kalla.
-
AuthorPosts
-
jeanlucnobourgMemberHere is my strutsconfig.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE struts-config PUBLIC “-//Apache Software Foundation//DTD Struts Configuration 1.1//EN” “http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd”>
<struts-config>
<data-sources />
<form-beans >
<form-bean name=”loginForm” type=”com.yourcompany.struts.form.LoginForm” />
</form-beans><global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute=”loginForm”
input=”/Login.jsp”
name=”loginForm”
path=”/login”
scope=”request”
type=”com.yourcompany.struts.action.LoginAction”>
<forward name=”succes” path=”/Userlogin.jsp” />
<forward name=”failure” path=”/Login.jsp” />
</action>
</action-mappings>
<controller bufferSize=”4096″ debug=”0″ />
<message-resources parameter=”com.yourcompany.struts.ApplicationResources” />
</struts-config>************************************************************
when I do http://localhost:8400/TEST/login/Login.jsp
I get the following errors
http 404 the page could not be found.
when I do http://localhost:8400/TEST/Login.jsp
it works fine.
My confusion is that as I have /login in strutsconfig path the correct way to call should be http://localhost:8400/TEST/login/Login.jsp but it doesn’t work.
also when http://localhost:8400/TEST/Login.jsp ant it works and I click on the submit button nothing happen.
Here is my jsp<%@ page language=”java”%>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-bean” prefix=”bean” %>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-html” prefix=”html” %>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-logic” prefix=”logic” %>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-tiles” prefix=”tiles” %>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-template” prefix=”template” %>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-nested” prefix=”nested” %><!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html:html locale=”true”>
<head>
<html:base />
<title>Login.jsp</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”>
</head>
<body>
<html:form action=”login” >
password : <html:text property=”password”/>
<html:errors property=”password”/></br>
userName : <html:text property=”userName”/>
<html:errors property=”userName”/></br>
<html:submit/><html:cancel/>
</html:form></body>
</html:html>
Riyad KallaMemberjean,
Assuming you used the default path mapping in your web.xml file, the way you call this action is http://localhost:8400/TEST/login.do, that .do will trigger the ActionServlet from Struts to parse off the “.do” part and then look in the struts-config.xml file for anything matching “/login”, it will find your action and execute it. You will most likely want people to go to your Login.jsp page first, and you will have your form’s action path poin to “/login.do” so that your login form’s data will be sent to your Action. I suggest picking up Struts in Action as its an excellent book when getting started with Struts, you can grab the eBook from manning or Amazon for $22 or so. -
AuthorPosts