struts

Redirect or forward

耗尽温柔 提交于 2019-12-06 03:17:39
问题 Looking through some legacy code I have in front of me using struts one, I see: <global-forwards> ... <forward name="accessDenied" path="/www/jsp/AccessDeniedForm.do" redirect="true" /> </global-forwards> So it's just a global forward to send to a access denied page. I am curious about the decision to redirect as opposed to forward. What are the advantages and disadvantages of using it? 回答1: What are the pro's and con's of using it? Before discussing pro's and con's of using that forward

struts2-rest plugin..making both struts actions + rest actions work together but. giving java.lang.reflect.InvocationTargetException

不想你离开。 提交于 2019-12-06 02:43:36
I am converting my existing struts 2 application to serve through some rest based services also. I have used two plugins, struts2-rest plugin and struts-convention plugin, Along with these I have also used asm.jar because above was giving a class not found exception which was there in asm jar. I want to have both the functionalities as ..my normal struts action mappings should also work along with rest urls. struts.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">

Struts2 action - test it or not?

佐手、 提交于 2019-12-06 02:35:35
I'm currently working on one project, that uses Struts2 framework. We use separate component for DB accessing, which is well tested. At the same time, project, that we work on has a lot of Actions, that are not tested. In most of the actions we use at least one DB-service call. So on one hand these actions are pretty simple. I'm not sure - should unit tests be written for that or not? I think that good practice is write unit tests always, but these actions are so simple and I'm under big pressure from management side right now. So, is it critical or not - to leave Struts2 actions without unit

Struts2 的 struts.xml 配置中 namespace 的使用

社会主义新天地 提交于 2019-12-06 02:29:39
Struts2 的 struts.xml 中是分 package 配置的,可以为 package 设置 namespace 属性,如 <package namespace="/secure" ....> ...... </package> 如果没有指定 namespace 属性,默认 namespace 是 ""。使用 namespace 可以方便于按不同目的规划对应用的访问规则。比如不同 namespace 下配置了不同的拦截器就可以实现权限的控制,如 "/secure" 下已登陆用户才能访问,"/public" 下可公开访问的。 配置了 namespace 直接就是反应在访问 URL 上,例如 namespace="/secure" name="test" 的 action <package namespace="/secure" ....> <action name="test" .... </package> 访问它的 URL 就是 http://ip:port/context/secure/test.action ,那如果在 namespace "/secure" 下没有 test action 会出现什么情况呢?Struts 还会尝试在默认 namespace,即 "" 下找 test。 再举个例子,URL 是 http://ip:port/context/some

java.lang.NoClassDefFoundError: org/springframework/web/context/ContextCleanupListener issue

旧巷老猫 提交于 2019-12-06 02:21:05
I get this error SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.NoClassDefFoundError: org/springframework/web/context/ContextCleanupListener at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:80) at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5035) at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5687) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) at org.apache

BeanUtils.copyProperties与PropertyUtils.copyProperties用法及区别

岁酱吖の 提交于 2019-12-05 21:01:58
一、简介: BeanUtils提供对Java反射和自省API的包装。其主要目的是利用反射机制对JavaBean的属性进行处理。我们知道,一个JavaBean通常包含了大量的属性,很多情况下,对JavaBean的处理导致大量get/set代码堆积,增加了代码长度和阅读代码的难度。它需要Collections包和logging包的支持。 二、用法: BeanUtils是这个包里比较常用的一个工具类,这里只介绍它的copyProperties()方法。该方法定义如下: public static void copyProperties(java.lang.Object dest,java.lang.Object orig) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException 如果你有两个具有很多相同属性的JavaBean,一个很常见的情况就是Struts里的PO对象(持久对象)和对应的ActionForm,例如 Teacher和TeacherForm。我们一般会在Action里从ActionForm构造一个PO对象,传统的方式是使用类似下面的语句对属性逐个赋值: //得到TeacherForm TeacherForm teacherForm=(TeacherForm

Has anyone migrated from Struts 1 to another web framework?

前提是你 提交于 2019-12-05 20:39:08
问题 On my current project, we've been using Struts 1 for the last few years, and ... ahem ... Struts is showing its age. We're slowly migrating our front-end code to an Ajax client that consumes XML from the servers. I'm wondering if any of you have migrated a legacy Struts application to a different framework, and what challenges you faced in doing so. 回答1: Sure. Moving from Struts to an AJAX framework is a very liberating experience. (Though we used JSON rather than XML. Much easier to parse.)

搭建Java Web项目问题总结

帅比萌擦擦* 提交于 2019-12-05 20:19:42
‍ 1.Target runtime com.genuitec.runtime.generic.jee60 is not defined. ‍ 解决方案是 : 在工程目录下的 .settings 文件夹里,打开 org.eclipse.wst.common.project.facet.core.xml 文件 , 其内容为 : <?xml version="1.0" encoding="UTF-8"?> 2 <faceted-project> 3 <runtime name="com.genuitec.runtime.generic.jee60"/> 4 <fixed facet="wst.jsdt.web"/> 5 <fixed facet="jst.web"/> 6 <fixed facet="java"/> 7 <installed facet="java" version="1.6"/> 8 <installed facet="jst.web" version="3.0"/> 9 <installed facet="jst.web.jstl" version="1.2.1"/>10 <installed facet="wst.jsdt.web" version="1.0"/>11 </faceted-project> 更改 <runtime name="?"> 内容为

What's the Difference Between <s:property ..> and ${param}

匆匆过客 提交于 2019-12-05 14:24:21
In struts I notice there are two different ways to access variables. I am curious what the difference is and when to properly use each one. For example, suppose we set the variable height like so: <s:set var="height">300px</s:set> Now I can use it two ways: <div style="height: ${height}"> </div> ..or.. <div style="height: <s:property value='#height' />"> </div> What is the difference, and which is better to use? The struts2 <property> provides additional functionality beyond what ${} offers, such as providing a default value if the variable is null, and control over HTML-escaping. Also you can

Executing multiple actions one after another

吃可爱长大的小学妹 提交于 2019-12-05 11:16:38
I am in need of a way of executing multiple struts actions with one request. The goal is to minimize the need of request against the server. So what i need is something like a "MultiAction" which gets a list of actions as its parameters which it should execute and then return a "combined" result of this actions. For example: The client is split up in a lot of modules One module needs to get information from the server There is a proxy at the client handling this request This proxy now goes and say "Hey you other modules, i'm going to make a rquest to the server, you need anything?" The other