1. page test address format :
http://localhost:8080/Structs_t/user/user!add?user.name=bbbb&user.age=8,
page is displayed correctly.
2.structs an xml
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<package name="user" extends="struts-default" namespace="/user">
<action name="user" class="com.structs2.Action3">
<result>/user_add_success.jsp</result>
</action>
</package>
3. corresponding Action3
package com.structs2;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class Action3 extends ActionSupport {
private String name;
private int age;
public String add() {
System.out.println("name=" + name);
System.out.println("age=" + age);
return SUCCESS;
}
public String getName() {
return name;
}
public void setName(String name) {
System.out.println("Test!!!!");
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
everything else is normal , the only problem is the console always print
name = null
age = 0
really do not understand , why is not the printed page into the Senate , and setName no printing machines are rebooted , the server debug times, as well.
Seek expert Q & A, very grateful .
------ Solution ------------------------------------ --------
http://localhost:8080/Structs_t/user/user!add.action?name=bbbb&age=8
------ For reference only - -------------------------------------
http://localhost:8080/Structs_t/ user / user! add? name = bbbb & age = 8
------ For reference only ------------------------- --------------
same results

------ For reference only ---------------------------------- -----
address before the test is no problem , no extra . action. May be the Web Browser settings myeclipse problem in the browser to test no problem. Thank you .
------ For reference only ---------------------------------- -----
you can try calling the get method . . .
没有评论:
发表评论