首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >包括css在内的基于vaadin的春季项目

包括css在内的基于vaadin的春季项目
EN

Stack Overflow用户
提问于 2019-03-18 17:12:19
回答 1查看 429关注 0票数 0

尝试使用spring引导将简单的css文件包含到vaadin路由,并有一个maven项目。当我在客户端上加载页面时,我会得到以下错误:

代码语言:javascript
复制
Refused to apply style from 
'http://localhost:8080/frontend/css/msas_login_page.css' because its MIME 
type ('text/html') is not a supported stylesheet MIME type, and strict MIME 
checking is enabled.

当我试图访问上面的url时,我会被重定向到这个html错误页面。

代码语言:javascript
复制
Could not navigate to 'css/msas_login_page.css'
Reason: Couldn't find route for 'css/msas_login_page.css'

这是我的密码:

代码语言:javascript
复制
package com.msas.MSAS.UIControllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.web.context.annotation.SessionScope;

import com.msas.MSAS.UIControllers.Authentication.MSASLoginForm;
import com.vaadin.flow.component.dependency.StyleSheet;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.AfterNavigationEvent;
import com.vaadin.flow.router.AfterNavigationObserver;
import com.vaadin.flow.router.Route;

@Route("loginPage")
@VaadinSessionScope
@StyleSheet("css/msas_login_page.css")
public class MSASLoginPage extends HorizontalLayout implements
        AfterNavigationObserver {

    private static final long serialVersionUID = 8673461297922218502L;

    private MSASLoginForm loginForm;
    private VerticalLayout container;

    public MSASLoginPage(@Autowired MessageSource messageSource) {
        super();

        this.initComponents(messageSource);
    }

    private void initComponents(MessageSource messageSource) {
        this.loginForm = new MSASLoginForm(messageSource);

        this.container = new VerticalLayout();
        this.container.setDefaultHorizontalComponentAlignment(Alignment.CENTER);
        this.container.add(this.loginForm);

        this.addClassName("login-page-container");
        this.setDefaultVerticalComponentAlignment(Alignment.CENTER);
        this.setHeightFull();
        this.add(this.container);
    }

    @Override
    public void afterNavigation(AfterNavigationEvent event) {
        boolean isError = event.getLocation().getQueryParameters()
                .getParameters().containsKey("error");
        this.loginForm.setError(isError);
    }
}

以下是我的项目结构:

  • src
    • main

      • java

        • ..。

      • 资源

        • ..。

      • webapp

        • 前部

          • css

          • msas_login_page.css

这是css文件内容:

代码语言:javascript
复制
.login-page-container{
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-19 09:25:29

解决了这个问题。

我使用的是一个多模块maven项目,包含@SpringBootApplication并运行整个应用程序的主要方法不在vaadin前端文件夹所在的模块中。

解决方案是将主类移动到与vaadin使用的maven模块相同的模块中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55226679

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档