Struts2 整合Extjs
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<constant name="struts.action.extension" value="action"></constant>
<package name="base" namespace="/user" extends="struts-default">
<action name="uploadbook" class="com.xiva.action.common.UploadFileAction"
method="uploadBook"></action>
<action name="logout" class="com.xiva.action.user.LoginAction"
method="logout">
<result name="success">/main.jsp</result>
</action>
</package>
<package name="user" namespace="/user" extends="json-default">
<action name="login" class="com.xiva.action.user.LoginAction"
method="login">
<result type="json">
<param name="includeProperties">success,msg</param>
</result>
</action>
</package>
</struts>
添加两个Jar包,一个是json,另一个是struts-json-plugin
调用form的doAction时,总是执行failure下的方式:
添加了success属性后,并在result配置中 添加
<param name="includeProperties">success,msg</param>
即可。
要想通用,可能还需要优化。待续