Browse Source

解决个别内网发布地址不正确问题

wkeyuan 4 years ago
parent
commit
d3c429f41b

+ 5 - 0
src/main/java/com/key/common/utils/DiaowenProperty.java

@@ -9,6 +9,7 @@ import java.util.Properties;
 
 import com.key.common.plugs.version.VersionInfo;
 import com.key.common.utils.web.Struts2Utils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.struts2.ServletActionContext;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -28,6 +29,7 @@ public class DiaowenProperty extends
 		PropertyPlaceholderConfigurer {
 
 	public static String STORAGE_URL_PREFIX = null;
+	public static String DW_SERVER_WEBSITE_URL = null;
 
 
 //	private static Map<String, String> ctxPropertiesMap;
@@ -38,6 +40,9 @@ public class DiaowenProperty extends
 			Properties props) throws BeansException {
 		super.processProperties(beanFactoryToProcess, props);
 
+		String serverUrl = props.getProperty("dw.server.website.url");
+		if(StringUtils.isNotEmpty(serverUrl)) DW_SERVER_WEBSITE_URL  = serverUrl;
+
 		/*
 		ctxPropertiesMap = new HashMap<String, String>();
 		for (Object key : props.keySet()) {

+ 4 - 1
src/main/java/com/key/common/utils/JspToHtml.java

@@ -28,7 +28,10 @@ public class JspToHtml {
 	public void postJspToHtml(String postUrl, String filePath,String fileName, String sType, String surveyId) throws Exception{
 		HttpServletRequest request=Struts2Utils.getRequest();
 		//${pageContext.request.scheme}://${pageContext.request.serverName }:${pageContext.request.serverPort} pageContext.request.contextPath
-		String reqTarget = request.getScheme()+"://"+request.getServerName()+(request.getServerPort()==80?"":":"+request.getServerPort())+request.getContextPath();
+		String reqTarget = DiaowenProperty.DW_SERVER_WEBSITE_URL;
+		if(reqTarget==null) {
+			reqTarget = request.getScheme()+"://"+request.getServerName()+(request.getServerPort()==80?"":":"+request.getServerPort())+request.getContextPath();
+		}
 		reqTarget =reqTarget+"/toHtml";
 		//?url="+postUrl+"&filePath="+filePath+"&fileName="+fileName;
 		Map<String, String> map=new HashMap<String, String>();

+ 3 - 1
src/main/java/com/key/common/utils/ToHtmlServlet.java

@@ -147,7 +147,9 @@ public class ToHtmlServlet extends HttpServlet {
 		FileOutputStream out=null;
 		OutputStreamWriter osw = null;
 		try {
-			out=new FileOutputStream(savePath+File.separator+fileName);
+			String filePath = savePath+File.separator+fileName;
+			System.out.println("生成:"+filePath);
+			out=new FileOutputStream(filePath);
 			osw = new OutputStreamWriter(out,"UTF-8");
 			osw.write(content);
 			osw.close();

+ 1 - 0
src/main/resources/conf/application.properties

@@ -9,6 +9,7 @@ hibernate.dialect=org.hibernate.dialect.MySQLDialect
 hibernate.show_sql=false
 hibernate.format_sql=true
 ###-------------------------------------DW------------------------------###
+dw.server.website.url = http://localhost:8282/
 dw.storage.url_prefix =
 ###-------------------------------------版本信息------------------------------###
 dw.version.info=DWSurvey OSS V3.3.3