struts 相关问题

Apache Struts Web框架是一个免费的开源解决方案,用于创建Java Web应用程序。

如何从 JSP 调用操作方法并在 Struts 2 中传递参数

我在 JSP 中有以下代码,它将调用操作方法,然后传递参数值。 &l...

回答 1 投票 0

如何在 Struts 2 中访问 OGNL 跟踪评估?

我被告知要优化网络应用程序。为此,我使用 JProfiler。 我注意到很大一部分响应时间都花在表示层上。特别是当代码构建 HTML 代码时。

回答 2 投票 0

Struts 2 中的开关动作

我正在使用Struts,在我的项目中我有2个模块(管理员,用户)“管理员”有不同的操作,例如添加用户,删除用户,添加项目,删除用户和“用户&q...

回答 1 投票 0

从Struts 2.5升级到Struts 6问题

升级到 Struts 6.3.0.2 后,此 Ajax 调用不起作用。我已经在 pom.xml 中包含了 JQuery 插件。我认为问题是 sj:div。非常感谢对此的任何帮助 <%@ page contentTy...

回答 1 投票 0

Struts 2 到 Struts 6 迁移

Struts 2.5.34 到 Struts 6.3 迁移 目前我们的应用程序是 struts 2.5.3 版本。 随着 Apache 宣布停产,我们正在使用官方 migra 升级到 Struts 6(确切地说是 6.3)...

回答 1 投票 0

如何从 Struts 2 中的 Action 名称列表中获取请求类型(GET 或 POST)? [重复]

我想获取我的应用程序中存在的所有 struts 操作的所有 POST/GET 请求类型。 我使用了 struts2-config-browser-plugin 并获取了整个应用程序中的所有操作名称。 现在,我

回答 1 投票 0

Struts 2.1.6 中的ONGL

我正在使用 struts 2.1.6 和 ONGL。请参阅下面的代码,并告诉我应该在第 3 行和第 4 行中的哪里定义 标签的属性,例如宽度、高度、背景颜色等。 1) s:form 动作=“L...

回答 1 投票 0

处理请求时发生异常:JBWEB004036/struts2/jsp/common/jsp/common/globalAppError.jsp”未找到

收到此错误 JBWEB004036:找不到文件“/struts2/jsp/common/jsp/common/globalAppError.jsp”并且 谁可以帮我这个事, 我正在使用struts 6.3.0.2和wildfly 24.0.0和JSP 那...

回答 1 投票 0

Struts 响应原始字符串

我有一个 Struts 项目,我需要将响应作为原始字符串发送 struts.xml: <

回答 1 投票 0

Java MVC Struts 响应原始字符串

我有一个用 Struts (MVC) 制作的 Java 项目,我需要将响应作为原始字符串发送 struts.xml: 我有一个用 Struts (MVC) 制作的 Java 项目,我需要将响应作为原始字符串发送 struts.xml: <struts> <constant name="struts.devMode" value="true"></constant> <constant name="struts.ui.theme" value="simple"></constant> <constant name="struts.xwork.chaining.copyErrors" value="true"></constant> <constant name="struts.xwork.chainingcopyMessages" value="true"></constant> <package name="basicstruts6" extends="struts-default" namespace="/"> <default-action-ref name="init"></default-action-ref> <action name="init" class="some.class.path.mvc.ServiceTestAction" method="init"> <result name="success">/WEB-INF/app/index.jsp</result> </action> <action name="invokeService" class="some.class.path.mvc.ServiceTestAction" method="execute"> <result name="success">/WEB-INF/app/index.jsp</result> </action> </package> </struts> 在 <action name="invokeService" class="some.class.path.mvc.ServiceTestAction" method="execute"> 中,我想用我定义的原始字符串进行响应,而不使用 index.jsp 文件作为模型。 我仍然想要 some.class.path.mvc.ServiceTestAction 处理请求,但想直接写入响应编写器 同时我想设置响应的HTTP代码。如果出现错误,我想使用 HTTP 400 进行响应并将正文直接写入响应编写器。 如果您不想返回index.jsp作为结果,那么您应该在struts.xml中删除此代码 <result name="success">/WEB-INF/app/index.jsp</result> </ 在操作类 execute() 方法中 return SUCCESS 放置 return NONE。 如果您的操作类实现了 HttpServletRequest 和 HttpServletResponse,您可以获得 ServletRequestAware 和 ServletResponseAware。 您还可以阅读这个答案:How to get the request body and response body in apache struts2? - 使用 $.ajax. 发布 在操作 execute() 方法中,您使用 servlet API 向响应写入一些文本。类似的东西 PrintWriter writer = httpServletResponse.getWriter(); writer.println("hello server"); writer.flush(); httpServletResponse.setStatus(400);

回答 1 投票 0

Struts 2 选择带有数组列表值的标签

我正在开发一个简单的struts应用程序。在我的 JSP 中,我有一个下拉列表框(使用 s:select 标签)。我需要用操作类中的数组列表值填充这些值。我怎样才能做到这一点?什么

回答 2 投票 0

Struts 上的 Rest API

我目前正在为struts应用程序添加rest服务。我们使用的struts是1.x。我发现rest插件仅支持struts2,而且该插件也不是完全restful...

回答 2 投票 0

Struts - Struts 提供的 JSP 页面中 .tld 的 Taglib 指令

我正在开发一个基于Struts 的应用程序。我是 Struts 新手。我想在 JSP 页面中使用在 Struts 提供的 taglib 目录中指定的 html 标签。 但不知道如何使用它。我知道嗬...

回答 3 投票 0

从 Struts 2.3.37 迁移到 2.5.33

https://cwiki.apache.org/confluence/display/WW/Struts+2.3+to+2.5+migration 我已经按照上面的页面从struts 2.3迁移到struts 2.5。我有 更改了与struts men相关的包名称...

回答 1 投票 0

java.lang.NoSuchMethodError:org.apache.tiles.impl.BasicTilesContainer.setApplicationContext(Lorg/apache/tiles/request/ApplicationContext;)V

从 Struts 2.3.37 迁移到 Struts 2.5.33。 我已经参考了下面给出的页面 https://cwiki.apache.org/confluence/display/WW/Struts+2.3+to+2.5+migration 我在运行时遇到错误...

回答 1 投票 0

从 struts 2.3.37 迁移到 struts 2.5.33

我已参考以下页面 https://cwiki.apache.org/confluence/display/WW/Struts+2.3+to+2.5+migration 我在 tomcat (v9.0.45) 上运行时遇到错误 严重:发送异常

回答 1 投票 0

Struts 2 MVC 架构中的混乱

我正在研究Struts2的Action,了解到Struts 2中的Controller是FilterDispatcher,Model是Action。 但之前我知道 Action 和 FilterDispatcher 都是 Controller...

回答 2 投票 0

注册操作返回请求的资源不可用

我有一个包含以下代码的表单: 请报名 <... 我有一个包含以下代码的表单: <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" >

回答 2 投票 0

注册操作返回请求的资源不可用

我有一个包含以下代码的表单: 请报名 <... 我有一个包含以下代码的表单: <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" >

回答 2 投票 0

使用struts刷新页面的一部分而不使用ajax

各位,在struts中是否可以不使用ajax来刷新页面的一部分。请告诉我。

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.