Apache Struts Web框架是一个免费的开源解决方案,用于创建Java Web应用程序。
我有一个包含以下代码的表单: 请报名 <... 我有一个包含以下代码的表单: <form action="doRegister" class="form-signup" > <h2 class="form-signup-heading">Please sign up</h2> <input type="email" class="form-control" placeholder="Email address" required autofocus> <input type="password" class="form-control" placeholder="Password" required> <input type="password" class="form-control" placeholder="Password control" required> <input type="text" class="form-control" placeholder="Name" required> <input type="text" class="form-control" placeholder="Surname" required> <input type="date" class="form-control" placeholder="Born date" required> <button class="btn btn-lg btn-primary btn-block" type="submit">Sign up</button> </form 我有两个班级:UserRegisterForm和UserRegistrationAction UserRegisterForm: package com.github.jcpp.jathenaeum.action; import org.apache.struts.action.ActionForm; public class UserRegisterForm extends ActionForm{ private static final long serialVersionUID = 1; /*ATTRIBUTES of the form fields*/ /*METHODS Get and Set*/ public UserRegisterForm() { super(); } } UserRegistrationAction: package com.github.jcpp.jathenaeum.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.github.jcpp.jathenaeum.Utente; import com.github.jcpp.jathenaeum.db.dao.UtenteDAO; import com.github.jcpp.jathenaeum.exceptions.RegistrationException; public class UserRegistrationAction extends Action{ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //boolean action_perform = false; String action_target = null; Random rnd = new Random(); UtenteDAO userDao = new UtenteDAO(); Utente user = new Utente(); //ActionMessages errors_mesg = new ActionMessages(); UserRegisterForm uf = (UserRegisterForm) form; if(form != null){ user.setEmail(uf.getEmail()); user.setPassword(uf.getPassword()); user.setNome(uf.getName()); user.setCognome(uf.getSurname()); user.setDataNascita(uf.getBornDate()); user.setNumeroTessera(rnd.nextInt(999999)+1); try{ if(userDao.register(user)){ action_target = "success"; } }catch(Exception e){ action_target = "failed"; throw new RegistrationException(); } } return mapping.findForward(action_target); } 在我的struts-config.xml中我: <form-beans> <form-bean name="registerform" type="com.github.jcpp.jathenaeum.action.UserRegisterForm"/> </form-beans> <action-mappings> <action path="/index" type="org.apache.struts.actions.ForwardAction" parameter="page.index" /> <action path="/signin" type="org.apache.struts.actions.ForwardAction" parameter="page.signin" /> <action path="/signup" type="org.apache.struts.actions.ForwardAction" parameter="page.signup" /> <action path="/doRegister" type="com.github.jcpp.jathenaeum.action.UserRegistrationAction" name="registerform" scope="request" validate="true" input="signup"> <forward name="input" path="/index.jsp"/> <forward name="success" path="/welcome.jsp"/> <forward name="failure" path="/index.jsp"/> </action> </action-mappings> 我的错误报告是: 类型状态报告 留言 /JAthenaeum/doRegister 描述 请求的资源不可用。 为什么我会遇到这个问题? 问题在于表单中的 action 参数:在我的例子中它必须是 doRegister.do,而在 struts-config.xml 中,操作路径等于 /doRegister。所以,请看下面的代码: <form action="doRegister.do" > [...] </form> 并且在 struts-config.xml <action path="/doRegister" <!-- LOOK HERE --> type="com.github.jcpp.jathenaeum.action.UserRegistrationAction" name="registerform" scope="request" validate="true" input="/signup.jsp"> <!-- <forward name="input" path="/index.jsp"/> <forward name="success" path="/signin.jsp"/> <forward name="failed" path="/signup.jsp"/> --> </action> 该操作返回名为 "failed" 的未知转发。将其更改为配置为操作 "failure" 的值。应替换以下代码 try { if(!userDao.register(user)) { return mapping.findForward("failure"); } }catch(Exception e){ throw new RegistrationException(e); } return mapping.findForward("success"); 异常应该提供更多信息,告诉您异常的原因。 表格也应该映射到正确的操作 <html:form action="/doRegister" cssClass="form-signup" >
我有一个包含以下代码的表单: 请报名 <... 我有一个包含以下代码的表单: <form action="doRegister" class="form-signup" > <h2 class="form-signup-heading">Please sign up</h2> <input type="email" class="form-control" placeholder="Email address" required autofocus> <input type="password" class="form-control" placeholder="Password" required> <input type="password" class="form-control" placeholder="Password control" required> <input type="text" class="form-control" placeholder="Name" required> <input type="text" class="form-control" placeholder="Surname" required> <input type="date" class="form-control" placeholder="Born date" required> <button class="btn btn-lg btn-primary btn-block" type="submit">Sign up</button> </form 我有两个班级:UserRegisterForm和UserRegistrationAction UserRegisterForm: package com.github.jcpp.jathenaeum.action; import org.apache.struts.action.ActionForm; public class UserRegisterForm extends ActionForm{ private static final long serialVersionUID = 1; /*ATTRIBUTES of the form fields*/ /*METHODS Get and Set*/ public UserRegisterForm() { super(); } } UserRegistrationAction: package com.github.jcpp.jathenaeum.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.github.jcpp.jathenaeum.Utente; import com.github.jcpp.jathenaeum.db.dao.UtenteDAO; import com.github.jcpp.jathenaeum.exceptions.RegistrationException; public class UserRegistrationAction extends Action{ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //boolean action_perform = false; String action_target = null; Random rnd = new Random(); UtenteDAO userDao = new UtenteDAO(); Utente user = new Utente(); //ActionMessages errors_mesg = new ActionMessages(); UserRegisterForm uf = (UserRegisterForm) form; if(form != null){ user.setEmail(uf.getEmail()); user.setPassword(uf.getPassword()); user.setNome(uf.getName()); user.setCognome(uf.getSurname()); user.setDataNascita(uf.getBornDate()); user.setNumeroTessera(rnd.nextInt(999999)+1); try{ if(userDao.register(user)){ action_target = "success"; } }catch(Exception e){ action_target = "failed"; throw new RegistrationException(); } } return mapping.findForward(action_target); } 在我的struts-config.xml中我: <form-beans> <form-bean name="registerform" type="com.github.jcpp.jathenaeum.action.UserRegisterForm"/> </form-beans> <action-mappings> <action path="/index" type="org.apache.struts.actions.ForwardAction" parameter="page.index" /> <action path="/signin" type="org.apache.struts.actions.ForwardAction" parameter="page.signin" /> <action path="/signup" type="org.apache.struts.actions.ForwardAction" parameter="page.signup" /> <action path="/doRegister" type="com.github.jcpp.jathenaeum.action.UserRegistrationAction" name="registerform" scope="request" validate="true" input="signup"> <forward name="input" path="/index.jsp"/> <forward name="success" path="/welcome.jsp"/> <forward name="failure" path="/index.jsp"/> </action> </action-mappings> 我的错误报告是: 类型状态报告 留言 /JAthenaeum/doRegister 描述 请求的资源不可用。 为什么我会遇到这个问题? 问题在于表单中的 action 参数:在我的例子中它必须是 doRegister.do,而在 struts-config.xml 中,操作路径等于 /doRegister。所以,请看下面的代码: <form action="doRegister.do" > [...] </form> 并且在 struts-config.xml <action path="/doRegister" <!-- LOOK HERE --> type="com.github.jcpp.jathenaeum.action.UserRegistrationAction" name="registerform" scope="request" validate="true" input="/signup.jsp"> <!-- <forward name="input" path="/index.jsp"/> <forward name="success" path="/signin.jsp"/> <forward name="failed" path="/signup.jsp"/> --> </action> 该操作返回名为 "failed" 的未知转发。将其更改为配置为操作 "failure" 的值。应替换以下代码 try { if(!userDao.register(user)) { return mapping.findForward("failure"); } }catch(Exception e){ throw new RegistrationException(e); } return mapping.findForward("success"); 异常应该提供更多信息,告诉您异常的原因。 表格也应该映射到正确的操作 <html:form action="/doRegister" cssClass="form-signup" >
我需要在 Company 和 Employee 类中实现 ID 字段的自定义转换。我已经实现了从 StrutsTypeConverter 扩展的自定义转换器,并成功用于转换
有时每当我重新启动应用程序时,该应用程序是基于 爪哇 支柱 Mysql和Jboss 4.05版本 我收到错误地址已在使用中:JVM_Bind 我知道的唯一修复方法是重新启动
我的欢迎页面是 web.xml 文件中列出的welcome.jsp welcome.jsp 包含一个简单的表单,用于提交到由 struts-config.xml 文件映射的操作 所有映射都是正确的...
我正在创建一个 Struts-tiles 项目,具有以下基本细节
(1)我的欢迎页面是web.xml文件中列出的welcome.jsp (2)welcome.jsp 包含一个简单的表单,用于提交到由 struts-config.xml 文件映射的操作 (3)所有映射都是正确的...
我正在使用struts逻辑:迭代,我需要更改它写出的最后一行的样式。 我在 iterate 标签上有一个 bean:size 和 indexId,但我无法找出逻辑组合......
下面我给出了我的代码,它显示了一些错误,它说 org.apache.struts.action 不存在,我能做什么,请告诉我解决方案...... 导入 javax.servlet.http.HttpSession; 导入...
我的应用程序中有一个login.jsp 页面。我使用 Struts 2 和一个简单的 validate() 方法来验证我的表单。我有两个问题: 我的表单 bean 类中的 validate() 方法验证表单。 ...
在 spring-struts Web 应用程序中,DTO 对象如何从客户端传输到服务器而不实现可序列化
我有一个使用 Spring - Struts 框架开发的 Web 应用程序,部署在 Tomcat 8 服务器中。该应用程序仅托管在一台服务器上。 应用程序代码分层如下 行动|业务流程外包 | ...
我正在Struts2中做一个项目,我需要在URL中设置一个参数,就像下面链接中的用户参数一样。 我希望当我单击表单提交按钮而不是任何链接时传递此参数
我有一个旧的(~2005)java EE 项目,我想将其更新到最新的依赖项。 Web项目没有任何像maven或gradle这样的软件项目管理工具。 一些依赖...
struts中无权访问某个页面时如何重定向到homepage.do?
我的应用程序正在使用 Struts 1,页面受到角色保护(即:如果用户的角色不允许,则用户无法访问页面),使用页面中操作路径的属性“roles”...
我在从返回的 JSP 中的 struts 2 操作访问方法时遇到问题。据我了解,如果我有一个如下所示的操作: 公共类 HomeAction { 公共字符串前...
javax.servlet.UnavailableException:路径 /WEB-INF/struts-config.xml 缺少配置资源
我是 Struts 新手,我正在尝试使用 Struts 运行示例登录 Web 应用程序,但由于(javax.servlet.UnavailableException:缺少配置资源...
有没有办法获取当前渲染的 JSP,使用 JSTL 还是 Struts(或不使用)?就像 Python 和 PHP 中的 _ _ file _ _ 一样?
我正在尝试将 JMS 消息发送器集成到基于 struts 的 Web 应用程序中。我在一个方法中定义了消息发送者,并在actionForm的execute方法中调用了该方法。我得到的错误是
Struts 2 中的 ModuleConfig 和 PluginConfig
我正在从事 Struts 2 迁移工作。我的 Struts 1 应用程序正在使用 ModuleConfig 和 PlugInConfig 类。如何在 Struts 2 中使用这些类?
我想从操作方法返回一行。我的JSP如下 <%@ taglib prefix="s" uri="/struts-tags"%> <%@ taglib prefix="sj" uri="/struts-jquery-tag...