需求分析:在开发一些技术网站的时候,可能用到,如果想向你的用户传递网站的源码,可以使用plainText这个属性
例子:
<package name="p1" namespace="/test" extends="struts-default">
<action>
<result type="plainText">
<param name="localtion">/index.jsp</param>
<param name="charSet">UTF-8<param> //这是为了解决中文乱码问题!
<result>
<action>
<package>
返回结果:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is index<br/>
</body>
</html>
可以发现:返回结果,直接是网站的源码!