1
新無動作中的支柱&試圖去通過一個基本的教程,並正在錯誤InvalidPathException:http://localhost:8080/UserAction.do?method=add
找到指定的URL
我的網址含有炸燬的行動配置
這裏是我的一部分,struts-config.xml中
<struts-config>
<form-beans>
<form-bean name="UserForm" type="Form.UserForm" />
</form-beans>
<action-mappings>
<action path="/user" type="Action.UserAction" input="/pages/user.jsp" parameter="method" name="UserForm" scope="session">
<forward name="success" path="pages/user.jsp">
</action-mappings>
</struts-config>
我UserAction.Java
public class UserAction extends DispatchAction {
public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
//Do some stuff
UserForm userForm = (UserForm)form;
userForm.setMessage("Added user");
return mapping.findForward("success");
}
}
這裏是窗體
public class UserForm extends ActionForm {
private String message;
public UserForm() {
super();
}
public String getMessage() { return this.message; }
public void setMessage(String inMessage) { this.message = inMessage; }
}
最後我user.jsp
<html>
....
<html:form action="user">
<table>
<tr>
<td>
<html:submit value="add" onClick="submitForm()" />
</td> </tr></table></html:form>
</html>
submitForm簡單
function submitForm(){
document.forms[0].action = "UserAction.do?method=add"
document.forms[0].submit();