需求:把一个服务器上的配置文件内容显示到jsp内的一个div里。
1.struts2里的配置文件如下:
<package name="test" extends="default" namespace="/rims/test">
<action name="test" method="toLogin" class="com.supermap.earth.rims.action.auth.UserAuthAction">
<result name="success" type="plainText">/WEB-INF/classes/config/config.properties</result>
</action>
</package>
2.jsp页面代码如下:
$.post("${ctx}/rims/test/test.do").success(function(data){
alert(data);
$('#div1').appendHtml(data);
});
3. 这样data就是config.properties(要读取的配置文件)里的内容了。
拿到了config.properties的文件内容,如何添加到jsp里,就要用js了。这个就不用细说了。