actioncontext

Why use ServletRequestAware instead of ServletActionContext?

╄→гoц情女王★ 提交于 2020-12-04 04:59:56
问题 To get a servlet request in Struts 2 we can use either ServletRequestAware or ServletActionContext . However, in a particular internet resource, it is told that ServletRequestAware should be used instead of ServletActionContext . Does that have something to do with the fact that ServletActionContext will be a shared resource in a multi-threaded environment or is there any other reason behind this? 回答1: The ServletActionContext is a helper class that contains only static methods, one of them

How to print session attributes in jsp (struts)

元气小坏坏 提交于 2020-01-27 08:34:01
问题 Here is what I have: Java class (adding user): public String addUser() throws NoSuchAlgorithmException { HttpSession currentSession = request.getSession(); User u = new User(); u.setUname(getUserName()); u.setPassword(StringHash(getUserPass())); u.setUtype(getUserType()); plResponse = iUserDAO.addUser(u); setActionMessage(plResponse.getMessage()); currentSession.setAttribute("actionMessage", this.actionMessage); return SUCCESS; } Java class (adding associations): public String saveAssoc()

How to print session attributes in jsp (struts)

前提是你 提交于 2020-01-27 08:31:26
问题 Here is what I have: Java class (adding user): public String addUser() throws NoSuchAlgorithmException { HttpSession currentSession = request.getSession(); User u = new User(); u.setUname(getUserName()); u.setPassword(StringHash(getUserPass())); u.setUtype(getUserType()); plResponse = iUserDAO.addUser(u); setActionMessage(plResponse.getMessage()); currentSession.setAttribute("actionMessage", this.actionMessage); return SUCCESS; } Java class (adding associations): public String saveAssoc()

Struts2 JUnit ActionContext objects

Deadly 提交于 2019-12-30 11:38:07
问题 Problem: Struts ActionContext is null during test Using Struts2 JUnit plugin I have the following test: public class MainActionIT extends StrutsJUnit4TestCase { @Test public void testAction() { Map<String, Object> application = new HashMap<String, Object>(); application.put("options","home"); ActionContext.getContext().put("application",application); ActionProxy proxy = getActionProxy("/home"); String result = proxy.execute(); } } The two related classes are as follows: public class

Is it possible to configure unified format of date format for whole struts webapp?

别等时光非礼了梦想. 提交于 2019-12-29 02:01:05
问题 In any case id get exception Could not parse date . There is unified company standard of date format - 'dd/MM/yyyy' There are computers with different system locales. I am using jQueryUI for datepicker ( it is standard for widgets and already settled css styles to match application theme). At the beginning, i didn't found better solution then manually convert date string to date object using SimpleDateFormat object. Now i have converter class but still need to configure every Action that has

What is action context in Struts 2

怎甘沉沦 提交于 2019-12-25 04:24:13
问题 I don't understand this author: context, properties of the default or root object. ..based on a context I'm stuck at reading this portion of the tutorial: http://www.tutorialspoint.com/struts_2/struts_value_stack_ognl.htm "The OGNL is very similar to the JSP Expression Language. OGNL is based on the idea of having a root or default object within the context. The properties of the default or root object can be referenced using the markup notation, which is the pound symbol. As mentioned

How do you get a Struts2 value from the .properties file programatically?

北城余情 提交于 2019-12-22 18:50:38
问题 Say I have a struts.properties file with a defined value uploads.directory . How can I access that value from an Actioncontext programatically? 回答1: You can use getText("some.property.name") which return you the property value http://struts.apache.org/maven/struts2-core/apidocs/com/opensymphony/xwork2/ActionSupport.html 回答2: Create ActionSupport Object and by using getText() method of ActionSupport class. ActionSupport actionSupport = new ActionSupport(); actionSupport.getText("foo.bar"); 回答3

Mocking ActionContext.getContext().getSession() returns null

左心房为你撑大大i 提交于 2019-12-22 18:11:57
问题 I am trying to write jUnit test case for following method. public class MyClass { public static Map<String, Object> getSession() { Map<String, Object> session = ActionContext.getContext().getSession(); return session; } } I followed this question and also this question and tried to mock ActionContext . But still session is null . public class TestClass { private HttpServletRequest request; private HttpSession session; @Before public void setUp() { // mock the session session = mock

Struts2 Session Storage Location and Management

こ雲淡風輕ζ 提交于 2019-12-21 17:31:52
问题 I was reading Struts2 In Action, and it says for each request an ActionContext , a ValueStack and an Action instance are created, so they are thread safe. I was wondering how does the framework manages session, because it can't be stored in these locations, where does the actual Map gets stored, and how concurrent access to that Map is managed by the framework? 回答1: The http session is stored in the SessionMap which is among the other context maps is stored in the action context by the

Scopes of ActionMapper, ActionProxy, ActionInvocation, ActionContext objects in Struts2?

血红的双手。 提交于 2019-12-20 07:26:45
问题 Can any one please describe me when the objects of ActionMapper , ActionProxy , ActionInvocation , ActionContext are created in a Struts2 application. As I am new to Struts2 framework, I am very much confused about the scopes of these objects. 回答1: The ActionMapper is created on startup, it has a singleton scope. The ActionContext is created by the Dispatcher in preparing an action to execute, it's ThreadLocal, and it doesn't have any scope. When action is executing the ActionInvocation and