strut2服务器与android交互数据
libs如图:
web.xml:
[html]
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 定义Struts2的核心控制器:FilterDispatcher -->
<filter>
<!-- 定义核心Filter的名称 -->
<filter-name>struts2</filter-name>
<!-- 定义Filter的实现类 -->
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 定义Struts2的核心控制器:FilterDispatcher -->
<filter>
<!-- 定义核心Filter的名称 -->
<filter-name>struts2</filter-name>
<!-- 定义Filter的实现类 -->
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts.xml:
[html]
<?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">
<struts>
<constant name="struts.i18n.encoding" value="utf-8"></constant>
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
<package name="default" extends="json-default" namespace="/">
<action name="getjson" class="com.zte.android.LoginAction"
method="login">
<result type="json"></result>
</action>
</package>
</struts>
<?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">
<struts>
<constant name="struts.i18n.encoding" value="utf-8"></constant>
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
<package name="default" extends="json-default" namespace="/">
<action name="getjson" class="com.zte.android.LoginAction"
method="login">
<result type="json"></result>
</action>
</package>
</struts>
Student.java
[html]
package com.zte.android;
public class Student
{
private String name;
private String age;
private String school;
private String phone;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getAge()
{
return age;
}
public void setAge(String age)
{
this.age = age;
}
public String getSchool()
{
return school;
}
public void setSchool(String school)
{
this.school = school;
}
public String getPhone()
{
return phone;
}
public void setPhone(String phone)
{
this.phone = phone;
}
}
package com.zte.android;
public class Student
{
private String name;
private String age;
private String school;
private String phone;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getAge()
{
return age;
}
public void setAge(String age)
{
this.age = age;
}
public String getSchool()
{
return school;
}
publ
补充:移动开发 , Android ,