编的 一个简单的表单提交 可是总是 http400 在java吧 还被删帖 唉
index.jsp
- HTML code
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body><form method="POST"action="login.do"><input type="text" name="loginName"><input type="password" name="loginPass"><input type="submit" value="submit" ></body></html>
struts-config.xml
- XML code
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts-config SYSTEM "http://struts.apache.org/dtds/struts-config_1_3.dtd" ><struts-config> <form-beans> <form-bean name="LoginForm" type="app.LoginForm" /> </form-beans> <action-mappings> <action path="login" type="app.LoginAction" name="LoginForm" validate="false" scope="request"> <forward name="success" path="/success" /> <forward name="failure" path="/failure" /> </action> </action-mappings></struts-config>
------解决方案--------------------------------------------------------
1.确定你的web.xml里面配置了struts的相关信息
2.你的HTML的form没有闭合,在按钮之后加上</form>
------解决方案--------------------------------------------------------
表单没有闭合</form>
现在很多公司都用struts2了 建议你看看 它比struts1更好 我跟人感觉编写起来更简洁了
------解决方案--------------------------------------------------------
struts-config.xml配置的action路径加上/
- XML code
<action-mappings> <action path="/login" type="app.LoginAction" name="LoginForm" validate="false" scope="request"> <forward name="success" path="/success" /> <forward name="failure" path="/failure" /> </action> </action-mappings>
------解决方案--------------------------------------------------------
method的post可以大写?