2013年9月15日星期日

struts1 problems, hastily !

Baba Sports Network Project struts1.3 tomcat7.0 jdk7.0
browser to visit : http://localhost:8000/user/reg.do?method=regUI tips 404 , tomcat there is one thing wrong tips are not only a warning not know if there relationship
WARNING : [SetContextPropertiesRule] {Context} Setting property 'source' to 'org.eclipse.jst.jee.server: shop_01' did not find a matching property.

debugging a bit, feeling struts-config.xml web.xml Skip It seems to go wrong , because the struts-config.xml configuration file inside me how to pass parameters to change are not error messages , such as form- bean's name is inconsistent with the action of the name change does not give prompt error.

a whole afternoon did not result , worried to death I , and which brother to help look where is the problem .


key code as follows :
web.xml

xmlns = "http://java.sun.com/xml/ns/j2ee"
xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi: schemaLocation = "http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">



contextConfigLocation
classpath: beans.xml



org.springframework.web.context.ContextLoaderListener



struts
org.apache.struts.action.ActionServlet

config
/ WEB-INF/struts-config.xml

0


struts
*. do


/ index.jsp




struts-config.xml

"- / / Apache Software Foundation / / DTD Struts Configuration 1.3 / / EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">










;




BuyerRegAction.java
package cn.itcast.web.action.user;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.springframework.stereotype.Controller;
@ Controller ("/ user / reg")
public class BuyerRegAction extends DispatchAction {

public ActionForward regUI (ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
System.out.println ("comein");
return mapping.findForward ("regUI");
}

}


BuyerForm.java
package cn.itcast.web.formbean.user;
import org.apache.struts.action.ActionForm;
public class BuyerForm extends ActionForm {
private String username;
private String password;
private String email;

public void BuyerForm () {
System.out.print ("come in"); / / here no console output , should not enter here
}


public String getUsername () {
return username;
}
public void setUsername (String username) {
this.username = username;
}
public String getPassword () {
return password;
}
public void setPassword (String password) {
this.password = password;
}
public String getEmail () {
return email;
}
public void setEmail (String email) {
this.email = email;
}

}

------ Solution ------------------------------------ --------
project name is not forgot
http://localhost:8000/ Project Name / user / reg.do? method = regUI
------ Solution ------------ --------------------------------
 visual inspection is not with the project name . .
------ For reference only -------------------------------------- -
indeed yes ah, forgot to put the project into the empty context root
------ For reference only ---------------------------------------
indeed yes ah, forget the project the context root into empty

没有评论:

发表评论