struts配置问题
org.xml.sax.SAXParseException:Documentisinvalid:nogrammarfound.org.xml.sax.SAXParseEx...
org.xml.sax.SAXParseException: Document is invalid: no grammar found.
org.xml.sax.SAXParseException: Document root element "struts-config", must match DOCTYPE root "null".
启动tomcat报这两个错误 但是还是能启动成功的!
我用的是struts-2.1.8.1这个版本的
<?xml version="1.0" encoding="UTF-8"?>
<struts-config>
<form-beans>
<form-bean name="loginForm" type="com.jbsxt.strutstest.LoginActionForm" />
</form-beans>
<action-mappings>
<action path="/login" type="com.jbsxt.strutstest.LoginAction" name="loginForm" scope="request">
<forword name="success" path="/login_success.jsp"></forword>
<forword name="error" path="/login_error.jsp"></forword>
</action>
</action-mappings>
</struts-config>
需不需要<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN""http://struts.apache.org/dtds/struts-config_2_1.dtd">
这句话的??
public class LoginAction extends Action{
public ActionForward execute(ActionMapping mapping,ActionForm form,
HttpServletRequest request, HttpServletResponse response){
LoginActionForm loginForm = (LoginActionForm)form;
String username=loginForm.getUsername();
String password=loginForm.getPassword();
if("admin".equals(username) && "admin".equals(password)){
return mapping.findForward("success");
}
else{
return mapping.findForward("error");
}
}
这里能得到password和username的值 但是 return mapping.findForward("success");运行到这步就报错了 说没有<forword name="success">
我的web.xml都OK的 展开
org.xml.sax.SAXParseException: Document root element "struts-config", must match DOCTYPE root "null".
启动tomcat报这两个错误 但是还是能启动成功的!
我用的是struts-2.1.8.1这个版本的
<?xml version="1.0" encoding="UTF-8"?>
<struts-config>
<form-beans>
<form-bean name="loginForm" type="com.jbsxt.strutstest.LoginActionForm" />
</form-beans>
<action-mappings>
<action path="/login" type="com.jbsxt.strutstest.LoginAction" name="loginForm" scope="request">
<forword name="success" path="/login_success.jsp"></forword>
<forword name="error" path="/login_error.jsp"></forword>
</action>
</action-mappings>
</struts-config>
需不需要<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN""http://struts.apache.org/dtds/struts-config_2_1.dtd">
这句话的??
public class LoginAction extends Action{
public ActionForward execute(ActionMapping mapping,ActionForm form,
HttpServletRequest request, HttpServletResponse response){
LoginActionForm loginForm = (LoginActionForm)form;
String username=loginForm.getUsername();
String password=loginForm.getPassword();
if("admin".equals(username) && "admin".equals(password)){
return mapping.findForward("success");
}
else{
return mapping.findForward("error");
}
}
这里能得到password和username的值 但是 return mapping.findForward("success");运行到这步就报错了 说没有<forword name="success">
我的web.xml都OK的 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询