标签: struts-1

如何在Struts 1.2中的.properties文件中转义大括号

我需要在我呈现的JSP代码中保留属性文件中的花括号.可能吗?

我曾尝试类似的选项:\{,'{,{{,'{',/{,但没有帮助.

在运行时,我得到一个例外:

java.lang.IllegalArgumentException:无法解析参数号

问题是struts将其{}作为运行时值的占位符进行处理.任何帮助非常感谢.

java struts escaping struts-1

5
推荐指数
1
解决办法
6217
查看次数

是会话范围或请求范围中的这个struts 1.x表单bean吗?

我一直在寻找一个具体的答案,因为谷歌回复了很多很老的帖子.这是greetingActionForm在请求范围内还是在会话范围内?有没有除了任何位置action,并form-bean声明以确定窗体的范围是什么?

<action-mappings>
    <action path="/hello/my/oldfriend"
            type="com.imFine.HowAreYouAction"
            name="greetingActionForm"
            validate="true"
            input="/the/front/door">
        <forward name="success" path="/go/get/drinks.do" />
    </action>
</action-mappings>
<form-beans>
    <form-bean name="greetingActionForm" type="com.forms.GreetingActionForm"/>
</form-beans>
Run Code Online (Sandbox Code Playgroud)

forms scope struts-1 struts-config

5
推荐指数
1
解决办法
1万
查看次数

如何预选struts html:单选按钮

如何预选struts 1 html:单选按钮?

谢谢Maria

struts-1

5
推荐指数
1
解决办法
2万
查看次数

Struts 1.3中的多个"提交"按钮

我的JSP中有这个代码:

<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
..
..
<html:form action="update" >
  ..
  ..
  <html:submit value="delete" />
  <html:submit value="edit" />
  <html:sumit value="update" />
</html:form>
Run Code Online (Sandbox Code Playgroud)

这在struts-config.xml文件中:

<action path="/delete" name="currentTimeForm" input="/viewall.jsp" type="com.action.DeleteProduct">
   <forward name="success" path="/viewall.jsp" />
   <forward name="failure" path="/viewall.jsp" />
</action>
Run Code Online (Sandbox Code Playgroud)

就像delete行动一样,我有editupdate.它工作正常,如果我给的名字特别喜欢<html:form action="delete">,但是,如何使之成为工作动态updateedit

struts struts-1

5
推荐指数
1
解决办法
2万
查看次数

如何在Struts 1中使用Tiles2

是否可以在Struts 1中使用Tiles2?

我已按照迁移指南http://tiles.apache.org/migration/index.html上的说明进行操作

但是当我尝试访问我的操作时,我收到此错误:

org.apache.tiles.template.NoSuchAttributeException: Attribute 'body' not found.
Run Code Online (Sandbox Code Playgroud)

我有struts-config.xml:

<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"
    maxFileSize="10M" tempDir="/tmp" />

<plug-in className="org.apache.struts.tiles.TilesPlugin">
    <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
</plug-in>
Run Code Online (Sandbox Code Playgroud)

和tiles-defs.xml

    <definition name="mainTemplate" template="/common/templates/mainTemplate.jsp" />
    <definition name="index" extends="mainTemplate">
        <put-attribute name="body" type="string" value="/views/index/index.jsp"  />
    </definition>
Run Code Online (Sandbox Code Playgroud)

java tiles tiles2 struts-1

5
推荐指数
1
解决办法
1380
查看次数

在Struts 1.3中将数据从Action传递到view(jsp)的最佳实践是什么?

我正在用Struts 1.3编写Web应用程序。我想将Employee的ArrayList传递给JSP页面。

我看到以下两个方法:

1. 将Employee List作为字段放入ActionForm中。

List<Employee>  employees;
Run Code Online (Sandbox Code Playgroud)

动作类设置此字段:

empForm.setEmployees(employeeList);
Run Code Online (Sandbox Code Playgroud)

而JSP使用此数据为:

${empForm.employees}
Run Code Online (Sandbox Code Playgroud)

2. 直接将雇员列表放入请求中。

动作类将employeeList设置为请求。

request.setAttribute("employees", employeeList);
Run Code Online (Sandbox Code Playgroud)

在JSP中:

${employees}
Run Code Online (Sandbox Code Playgroud)

请提出我应该采用哪种方法。在Struts 1.3中,哪一种被认为是一种好习惯

jsp struts web-applications java-ee struts-1

5
推荐指数
1
解决办法
5154
查看次数

取消选中复选框时,struts复选框标记提交了什么值

我遇到了这种情况.

class MyForm extends IdSelectionForm {
  private Boolean approveIt = true;
  .....
}
Run Code Online (Sandbox Code Playgroud)

我的JSTL表格由

<html:checkbox property="approveIt" styleId="style1" value="true"/>
Run Code Online (Sandbox Code Playgroud)

当我选择复选框并提交时.在struts动作中,我获得了该字段的真实值集.当我取消选中并提交时再次.然后我也得到了真正的价值.我想知道它是否具有默认值.当我取消选中时,它是否应该被错误覆盖.

checkbox jsp struts-1

5
推荐指数
1
解决办法
2万
查看次数

将链接值传递给bean

我有一个JSP文件,其中包含如下链接:

<a href="links.do?method=homeAdmin">
<a href="links.do?method=signUp">
Run Code Online (Sandbox Code Playgroud)

我有一个动作类LinkAction.java:

public class LinkAction extends org.apache.struts.action.Action {

    public ActionForward signUp(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        return mapping.findForward("signUp");
    }
    public ActionForward homeAdmin(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        return mapping.findForward("homeAdmin");
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是它不起作用.但是当我把它改成这样的东西时,它只适用于signUp动作.

public class LinkAction extends org.apache.struts.action.Action {

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        return mapping.findForward("signUp");
    }

}
Run Code Online (Sandbox Code Playgroud)

我也尝试过把它改成

public class LinkAction extends DispatchAction …
Run Code Online (Sandbox Code Playgroud)

html java jsp struts-1

5
推荐指数
1
解决办法
906
查看次数

如何从AngularJS帖子中获取Struts中的数据

我正在使用带有Angular的Struts1.2来发布一些数据,并希望在java中获取数据.

我能够从服务器检索数据并能够在屏幕上显示它.

现在我试图用Angular将一些数据发布到服务器并尝试从request.getParameterjava中获取数据.我做了三次尝试,但我不能.

下面我还提供了以下文件,包括我的三次尝试的说明和截图.

1. CartController.js

var myApp = angular.module('cartApp',[]);

myApp.controller('CartController', function ($scope,$http) {

    $scope.bill = {};

    $scope.items = [];

    $http.post('/StrutsWithAngular/shopingCart.do')
        .success(function(data, status, headers, config) {

            $scope.items = data;
         })
        .error(function(data, status, headers, config) {
            //alert("Error :: "+data);
        });

    // First Try

    $scope.postData = function() {

         $http({
              method: 'POST',
              url: '/StrutsWithAngular/shopingCart.do',
              data: 'value=' + 'Parameter From Request' ,
              headers: {'Content-Type': 'application/x-www-form-urlencoded'}
           }).success(function(data, status, headers, config) {

            alert("Success :: "+status);

            $scope.items = data;
           }).error(function(data, status, headers, config) {

            alert("Error …
Run Code Online (Sandbox Code Playgroud)

java json struts-1 angularjs

5
推荐指数
1
解决办法
1万
查看次数

Struts struts-config.xml动作映射说明

我对Struts框架不熟悉。我试图了解动作映射的工作原理。假设我有一个发送AJAX请求的JavaScript文件:

$("button").click(function(){
    $.ajax({url: "myTestUrl.do", success: function(result){
        //do something with result
    });
});
Run Code Online (Sandbox Code Playgroud)

我的struts-config.xml文件如下所示:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
    <form-beans>
        <form-bean name="testForm" type="com.test.TestForm"/>       
    </form-beans>

    <!-- Global Forwards -->    
    <global-forwards>
    </global-forwards>

    <!-- Action Mappings -->
    <action-mappings>

        <action path="/myTestUrl" 
                type="com.test.TestAction" 
                name="testForm" 
                scope="request" />

    </action-mappings>
    <controller locale="true"/>
</struts-config>
Run Code Online (Sandbox Code Playgroud)

我不明白之间的关系actionform-bean。我的请求会由处理TestAction吗?如果是这样,那么表单bean type属性的目的是什么?

更新

对于需要全面了解Struts MCV框架的任何人,请查看以下链接:http : //www.javaranch.com/journal/2002/03/newslettermar2002.jsp#struts

struts-1 struts-config

5
推荐指数
1
解决办法
1万
查看次数