我在struts.xml中声明了以下操作:
<action path="/updateAccountInfo"
type="org.myCompany.UpdateAccountAction"
name="myAccountForm"
scope="session"
validate="true"
parameter="method"
input="/updateAccountInfo.jsp">
<forward name="success" path="/updateAccountInfo.jsp" />
</action>
Run Code Online (Sandbox Code Playgroud)
在我的JSP页面中,我有以下形式:
<html:form action="/updateAccountInfo.do">
<input type="hidden" name="method" value="sendMessage" />
Run Code Online (Sandbox Code Playgroud)
在我的java类中,我有以下方法:
public final ActionForward sendMessage(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
System.out.println("sending");
return null;
}
Run Code Online (Sandbox Code Playgroud)
Struts不是运行sendMessage,而是调用execute方法.为什么?我的struts-config错了吗?或者我错过了另一个配置设置?
我希望在点击html页面中的html链接时执行Struts2操作.我的第一个问题是,是否可以在html页面(而不是JSP)中执行Struts2操作?如果是,请查看下面的代码:
home.html的
HREF = "home.action"
在struts.xml
action name ="home"class ="com.struts.action.HomeAction"
Run Code Online (Sandbox Code Playgroud)result name="Success">loginJSP.jsp
*****web.xml*****我做了过滤映射,以便所有内容都转到Struts2
应该在JSP文件的开头添加以<%@开头的行,以便能够使用该标记.
我在jsp的开头添加了以下行.
<%@ taglib prefix ="html"uri ="http://struts.apache.org/tags-html"%>
但Eclipse IDE说
在Java Build Path中找不到 "html:link"(org.apache.struts.taglib.html.LinkTag)的标记处理程序类
在< html:link >标记旁边.
这有什么不对?
我想要做的是 - 通过struts actionmapping 从homepage.jsp加载page1.jsp.
我正在尝试学习struts2,所以这是一个非常基本的问题.
我有一个页面input_database.jsp,以及它对应的类input_database.java
在类文件中,我有一个带有mutator和accessor的字符串的arraylist.我想在我的.jsp文件中显示它
我一直试图用a来做,但我认为我做的事情从根本上是错误的.
这是我一直试图在jsp文件中使用的代码.arraylist是一个名为query_data的私有字符串列表.我的最终目标是显示一个字符串arraylists的arraylist来显示我的select语句,但我需要先找出一些简单的字符串.如果有人知道我做错了什么,或者可以指出一个我忽略的教程,那就太棒了
谢谢
<s:iterator value="query_data" id="something">
<s:property value="something"/><br />
</s:iterator>
Run Code Online (Sandbox Code Playgroud) 如果在struts synchronized的service()方法中有一个块ActionServlet,那么如果多个请求/线程是一个拥有大量命中的繁忙站点,它将如何工作.
每个线程是否会等待下一个另一个线程从同步块释放锁定?会不会造成响应延迟
我需要使用javascript关闭按钮单击窗口.
但是,在关闭窗口之前,我想提交表单(我正在使用struts2.它是一个java web应用程序).
那么如何提交数据以便同时保存和关闭窗口.这是一种弹出窗口.下面是jquery代码,我用来提交表单.
function fnSubmit() {
$('#adminpopup').attr('action','submitPopupAction').submit();
}
Run Code Online (Sandbox Code Playgroud)
编辑:我在这里还有一个约束.当我单击提交按钮时,表单将被提交.如果从服务器端代码返回时出现错误,我将不得不在弹出窗口中显示错误消息.如果成功,请关闭弹出窗口.
我想这不能通过简单地一个接一个地调用javascript函数来实现.有没有办法实现这个目标?
请帮我.我面临这个错误3天.我在网上搜索了所有的例子,但我无法弄明白.
这些是我的文件:
在struts.xml
...
<action name="menu" class="com.struts.actions.MenuAction" method="asdf">
<result name="success" type="tiles">struts2tiles.home</result>
</action>
...
Run Code Online (Sandbox Code Playgroud)
menu2.jsp
....
<body>
<s:form action="menu">
<s:checkboxlist label="What's your favor color" list="colors" name="colors" />
<s:submit value="submit" name="submit" />
</s:form>
</body>
Run Code Online (Sandbox Code Playgroud)
MenuAction
public class MenuAction extends ActionSupport {
private ArrayList<String> colors;
private String yourColor;
public ArrayList<String> getColors() {
return colors;
}
public void setColors(ArrayList<String> colors) {
this.colors = colors;
}
public String getYourColor() {
return yourColor;
}
public void setYourColor(String yourColor) {
this.yourColor = yourColor;
}
public String asdf() …Run Code Online (Sandbox Code Playgroud) 我在divjsp页面中添加了一个单选按钮.但是新添加的单选按钮总是在选择,当我点击第二个单选按钮时,它也会选择.有没有写入此脚本的脚本.
<div style="padding-left:15px">
<div>
Entry Mode Code was:
</div>
<div style="padding-left:30px">
<div>
<html:radio name="caseForm" property="questionnaire.RP0062.posEntryModeCd" value="A" styleId="posEntryModeCda"> 05 - Chip Card read (data is reliable)</html:radio>
</div>
<div>
<html:radio name="caseForm" property="questionnaire.RP2462.posEntryModeCd" value="B"> 90 - Magnetic Stripe Terminal and the full unaltered contents of the selected track is included</html:radio>
</div>
<div>
<html:radio name="caseForm" property="questionnaire.RP2462.posEntryModeCd" value="C" > Not Applicable</html:radio>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
附图:

我是Struts 2的新手,之前曾在Struts 1工作。
我们如何将错误消息与UI组件(例如,文本框)绑定在一起?我不希望该错误消息成为全局消息。
为了在Struts 1中实现相同效果:
在表单验证方法中,我使用了以下方法:
ActionErrors errors = new ActionErrors();
if(userName != null && userName.length() <= 0)
errors.add("userName",new ActionError("error.userName.required"));
Run Code Online (Sandbox Code Playgroud)
并在用户界面中显示消息:
<html:messages id="userName" property="userName">
<bean:write name="userName"/>
</html:messages>
Run Code Online (Sandbox Code Playgroud)
在Struts 2中,如果我扩展Action类ActionSupport并使用它:
addActionError(getText("Please enter UserId"));
Run Code Online (Sandbox Code Playgroud)
然后,这似乎是一条全局消息,可以使用以下命令在UI中显示:
<s:actionerror />
Run Code Online (Sandbox Code Playgroud)
因此,不确定如何在Struts 2中实现相同的功能。请让我知道这一点。
将数据记录保存到数据库时,我在SQL语法中出错:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'option, createdBy, createdDate, updatedBy, updatedDate, description) values ('QU' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1031)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2109)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2648)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2077)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2362)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2280)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2265)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94) …Run Code Online (Sandbox Code Playgroud)