小编Roh*_*der的帖子

utf 8 charset不适用于javax邮件

我使用Javax Mail API发送电子邮件.我使用联系方式发送输入,必须将其发送到特定的电子邮件.

发送电子邮件没有问题,虽然我是一个丹麦人,因此我需要三个丹麦字符,即'æ','ø'和'å',在主题和电子邮件文本中.

因此我看到我可以使用UTF-8字符编码来提供这些字符,但是当我的邮件发送时我只看到一些奇怪的字母 - 'ã|','ã¸'和'ã¥' - 而不是丹麦语字母 - 'æ','ø'和'å'.

我发送电子邮件的方法看起来像这样

public void sendEmail(String name, String fromEmail, String subject, String message) throws AddressException, MessagingException, UnsupportedEncodingException, SendFailedException
{
    //Set Mail properties
    Properties props = System.getProperties();
    props.setProperty("mail.smtp.starttls.enable", "true");
    props.setProperty("mail.smtp.host", "smtp.gmail.com");
    props.setProperty("mail.smtp.socketFactory.port", "465");
    props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.setProperty("mail.smtp.auth", "true");
    props.setProperty("mail.smtp.port", "465");
    Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {
        @Override
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication("my_username", "my_password");
        }
    });

    //Create the email with variable input
    MimeMessage mimeMessage = new MimeMessage(session);
    mimeMessage.setHeader("Content-Type", "text/plain; charset=UTF-8");
    mimeMessage.setFrom(new …
Run Code Online (Sandbox Code Playgroud)

java jakarta-mail utf-8 character-encoding

45
推荐指数
3
解决办法
6万
查看次数

Internet Explorer:"未定义控制台"错误

我正在使用console.log()我编写的一些JavaScript,并且错误:console is not defined在Internet Explorer中抛出(在其他浏览器中工作正常).

我已将其替换为:

if (console) console.log("...");

如果consoleundefined,我希望条件评估为false.因此,该声明console.log不会被执行,也不应该抛出错误.

相反,console is not defined at character 4抛出了错误:

这是IE漏洞吗?或者"if"条件是否真的非法?这似乎很荒谬,因为如果if (console)是非法的,那么也if (console==undefined)应该是非法的.

你应该如何检查undefined变量?

javascript console internet-explorer undefined internet-explorer-8

23
推荐指数
3
解决办法
4万
查看次数

如何在java应用程序上下文中使用spring MVC的<mvc:resources>标记?

我已经创建了"for now"一个简单而基本的Spring Web应用程序.我习惯将部署描述符作为简单的web.xml文件,然后将应用程序上下文作为xml文件.

虽然,现在我想尝试仅使用java文件创建我的整个spring Web应用程序.因此,我创建了我的WebApplicationInitializer,而不是正常的部署描述符,以及使用@Configuration批注的应用程序上下文.

部署描述符

package dk.chakula.config;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
/**
 *
 * @author martin
 * @since 12-1-2012
 * @version 1.0
 */
public class Initializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext servletContext)
            throws ServletException {
        registerDispatcherServlet(servletContext);
    }

    private void registerDispatcherServlet(final ServletContext servletContext) {
        WebApplicationContext dispatcherContext = createContext(ChakulaWebConfigurationContext.class);
        DispatcherServlet dispatcherServlet = new DispatcherServlet(dispatcherContext);
        Dynamic dispatcher = servletContext.addServlet("dispatcher", dispatcherServlet);
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");
    }

    private WebApplicationContext createContext(final Class<?>... annotatedClasses) {
        AnnotationConfigWebApplicationContext …
Run Code Online (Sandbox Code Playgroud)

java spring-mvc

15
推荐指数
2
解决办法
2万
查看次数

两个外键,如何用laravel雄辩地图

我在MySQL中有两个表,第一个叫做用户,第二个叫做游戏.表结构如下.

用户

  • id(主要)
  • 电子邮件
  • 密码
  • 真正的名字

游戏

  • id(主要)
  • user_one_id(外国)
  • user_one_score
  • user_two_id(国外)
  • user_two_score

我的游戏桌与两个用户持有两个外交关系.

我的问题是如何为这个表结构建立模型关系?- 根据laravel文档,我应该在模型中创建一个函数并将其与其关系绑定

例如

public function users()
{
    $this->belongsTo('game');
}
Run Code Online (Sandbox Code Playgroud)

但是我似乎无法在文档中找到任何告诉我如何处理两个外键的内容.就像我上面的表结构一样.

我希望你能在这里帮助我.

谢谢

php mysql sql laravel eloquent

9
推荐指数
1
解决办法
9755
查看次数

Video JS - 如何更改字幕字体大小

我正在使用 Video JS,我发现它真的很棒,尽管我有一个问题,因为当播放器处于全屏状态时我无法更改字幕文本的字体大小。

我所做的就是更改 Video JS CSS 文件,将字体大小从 1.4em 更改为 4em。

/* Individual tracks */
.video-js .vjs-text-track {
  display: none;
  font-size: 1.4em;
  text-align: center;
  margin-bottom: 0.1em;
  /* Transparent black background, or fallback to all black (oldIE) */
  background: rgb(0, 0, 0); background: rgba(0, 0, 0, 0.50);
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用,它只会在视频播放器非全屏时更改字幕字体大小。

你能帮我解决这个问题吗?我使用的是 Video JS 版本 4.1

javascript css video video.js

2
推荐指数
1
解决办法
7457
查看次数