Commit c07effb8 authored by Quxl's avatar Quxl

xx

parent 3d7ca65f
...@@ -119,7 +119,7 @@ public class AdminFirstController { ...@@ -119,7 +119,7 @@ public class AdminFirstController {
locale = new Locale("en", "US"); locale = new Locale("en", "US");
} }
String subject = messages.get("email.getPassword.subject", locale); String subject = messages.get("email.getPassword.subject", locale);
String content = Common.getStringAsStream("classpath:/doc/first_pass_" + locale.getLanguage().toLowerCase() + "_" + locale.getCountry().toUpperCase() + ".txt"); String content = Common.getStringAsStream("doc/first_pass_" + locale.getLanguage().toLowerCase() + "_" + locale.getCountry().toUpperCase() + ".txt");
MessageFormat.format(content, member.getUsername(), memberFilm.getId()); MessageFormat.format(content, member.getUsername(), memberFilm.getId());
emailService.send(subject, content, member.getEmail()); emailService.send(subject, content, member.getEmail());
return Rjx.jsonOk(); return Rjx.jsonOk();
......
package com.egolm.film.util; package com.egolm.film.util;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Random; import java.util.Random;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import com.egolm.common.FileUtil; import com.egolm.common.FileUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
...@@ -29,8 +32,14 @@ public class Common { ...@@ -29,8 +32,14 @@ public class Common {
public static String getStringAsStream(String filename) { public static String getStringAsStream(String filename) {
logger.debug("read at classpath: " + filename); logger.debug("read at classpath: " + filename);
InputStream stream = Common.class.getClassLoader().getResourceAsStream(filename); Resource resource = new ClassPathResource(filename);
return new String(FileUtil.streamToBytes(stream)); try {
InputStream stream = resource.getInputStream();
return new String(FileUtil.streamToBytes(stream));
} catch (IOException e) {
logger.warn("", e);
return null;
}
} }
public static void main(String[] args) { public static void main(String[] args) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment