小编Mat*_*ias的帖子

ASP.NET C#捕获类中的所有异常

我知道这不是这样做的方式,而且根本不干净.我只是想知道是否可能.

如果我有一个带有一堆方法的类

public class Foo {

   methodA() {}

   methodB() {}

   methodC() {}

}
Run Code Online (Sandbox Code Playgroud)

是否有可能捕获所有可能发生的异常而无需在每个方法中编写try/catch?

c# asp.net exception-handling

18
推荐指数
2
解决办法
9362
查看次数

FlutterError:无法加载资产

这是我的应用程序的文件夹结构

.idea
.vscode
android
build
fonts
 Oxygen-Bold.tff
 Oxygen-Light.tff
 Oxygen-Regular.tff
images
 pizza0.png
 pizza1.png
ios
lib
 ui
  home.dart
 main.dart
test
.gitignore
.metadata
.packages
app_widgets.iml
pubspec.lock
pubspec.yaml
README.md
Run Code Online (Sandbox Code Playgroud)

在我的pubspec.yaml文件中,我像这样加载字体和素材资源

flutter:

uses-material-design: true

assets:
  - images/pizza0.png
  - images/pizza1.png

fonts:
  - family: Oxygen
    fonts:
      - asset: fonts/Oxygen-Regular.ttf
      - asset: fonts/Oxygen-Bold.ttf
        weight: 700
      - asset: fonts/Oxygen-Light.ttf
        weight: 300
Run Code Online (Sandbox Code Playgroud)

我没有收到此yaml文件的任何错误,并且运行“ flutter package get”给出的退出代码为0。

在我的home.dart中,我有以下课程:

class PizzaImageWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    AssetImage pizzaAsset = AssetImage('images/pizza0.png');
    Image image = Image(image: pizzaAsset, width: 400, height: 400); …
Run Code Online (Sandbox Code Playgroud)

assets flutter

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

PhpStorm + Xdebug =页面未加载

首先,有一些xdebug信息:

Xdebug installed: 2.2.0rc1
Server API: Apache 2.4 Handler Apache Lounge
Windows: yes - Compiler: MS VC9 - Architecture: x86
Zend Server: no
PHP Version: 5.4.0
Zend API nr: 220100525
PHP API nr: 20100525
Debug Build: no
Thread Safe Build: yes
Configuration File Path: C:\Windows
Configuration File: C:\Uniserver\UniServer\usr\local\php\php.ini
Extensions directory: C:\Uniserver\UniServer\usr\local\php\extensions

You're already running the latest Xdebug version
Run Code Online (Sandbox Code Playgroud)

一切都很好看.这就是我的php.ini的样子:

[Xdebug]
zend_extension=C:\Uniserver\UniServer\usr\local\php\extensions\php_xdebug-2.2.0RC1-5.4-vc9.dll
xdebug.remote_host=localhost
xdebug.remote_port=9123
xdebug.idekey=PHPSTORM
xdebug.remote_mode=req
xdebug.remote_handler=dbgp
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_autostart=0
xdebug.remote_log="C:\Uniserver\UniServer\usr\local\php\extensions\tmp\log.log"
xdebug.overload_var_dump=1
xdebug.trace_format=0
xdebug.show_exception_trace=0
xdebug.default_enable=0
Run Code Online (Sandbox Code Playgroud)

现在,我将尝试使用PhpStorm进行调试.首先我转到Settings-> PHP-> Servers并添加:

Name: localhost
Host: …
Run Code Online (Sandbox Code Playgroud)

php xdebug phpstorm

16
推荐指数
1
解决办法
1万
查看次数

Fancybox:iframe不起作用

非常简单的test.html页面:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    <script type="text/javascript" src="fancybox/jquery.fancybox.pack.js"></script>

    <link rel="stylesheet" href="fancybox/jquery.fancybox.css" type="text/css" media="screen"/>

    <script type="text/javascript">
        $(document).ready(function () {
            /* This is basic - uses default settings */

            $("a.iframe").fancybox();

        });
    </script>
</head>
<body>
<a class="iframe" href="http://www.google.be/">This goes to iframe</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

然而,fancybox只是不起作用...对js文件和css的引用是正确的.JQuery正常运行.但是单击该链接只是一个普通的链接.即:我重定向到google.be.仅供参考:这不仅仅是谷歌,而是我放在那里的每一个网址.我在这里错过了什么?

jquery fancybox

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

ASP.NET MVC3 Automapper Viewmodel/Model View验证

(再次,一个MVC验证问题.我知道,我知道......)

我想使用AutoMapper(http://automapper.codeplex.com/)来验证我的创建视图中的字段,以查找不在我的数据库中的字段(因此不在我的DataModel中).

示例:我有一个帐户/创建视图供用户创建新帐户,我想要一个密码和确认密码字段,因此用户必须输入两次密码才能确认.

数据库中的Account表如下所示:

Account[Id(PK), Name, Password, Email]
Run Code Online (Sandbox Code Playgroud)

我已经生成了一个ADO.NET实体数据模型,从中我使用ADO.NET自跟踪实体生成器生成了模型.

我还为[Required]等验证注释编写了一个自定义AccountViewModel.

总而言之,这是我的项目结构:

Controllers:
   AccountController

Models:
   Database.edmx (auto-generated from database)
   Model.Context.tt (auto-generated from edmx)
   Model.tt (auto-generated from edmx)
   AccountViewModel.cs

Views:
   Account
      Create.cshtml
Run Code Online (Sandbox Code Playgroud)

我的AccountViewModel的代码如下所示:

public class AccountViewModel
    {
        public int Id { get; set; }

        [Required]
        public string Name { get; set; }

        [Required]
        public string Password { get; set; }

        [Required]
        [Compare("Password")]
        public string ConfirmPassword { get; set; }
    }
Run Code Online (Sandbox Code Playgroud)

现在,我的Create View看起来像这样:

@model AutoMapperTest.Models.Account
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> …
Run Code Online (Sandbox Code Playgroud)

c# asp.net automapper asp.net-mvc-3

5
推荐指数
1
解决办法
7644
查看次数

使用Grid/FlowLayout的JProgressbar宽度

我正在研究一个现在看起来像这样的下载器:

截图

JFrame使用BorderLayout.在NORTH,我有一个JPanel(FlowLayout).在SOUTH中还有一个JPanel(FlowLayout),在WEST中我只有一个JTextArea(在JScrollPane中).这一切都正确显示.但是,在EAST中我目前有一个JPanel(GridLayout(10,1)).

我想在EAST部分中显示最多10个JProgressBars,它们是动态添加到面板中的.问题是,我不能让它们看起来像我想让他们看起来:我希望JProgressBars的宽度填满整个EAST部分,因为1)这使应用程序具有更加对称的外观和2)ProgressBars可能包含目前不适合的长串.我已经尝试将包含GridLayout(10,1)的JPanel放在flowlayout中,然后将该flowlayout放在EAST部分中,但这也不起作用.

我的代码(SSCCE)目前如下:

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;

public class Main {

    public static void main(String[] args) {
        new DownloadFrame();
    }

    private static class DownloadFrame extends JFrame {

        private JButton downloadButton;
        private JTextField threadIdTextField;
        private JTextArea downloadStatusTextArea;
        private JScrollPane scrollPane;
        private JTextField downloadLocationTextField;
        private JButton downloadLocationButton;

        private JPanel North;
        private JPanel South;
        private JPanel ProgressBarPanel;

        private Map<String, JProgressBar> progressBarMap;

        public DownloadFrame() {
            InitComponents();
            InitLayout();
            AddComponents();
            AddActionListeners();

            setVisible(true);
            setSize(700, 300);
        }

        private void …
Run Code Online (Sandbox Code Playgroud)

java swing grid-layout flowlayoutpanel border-layout

5
推荐指数
1
解决办法
3806
查看次数

ASP.NET MVC3双重验证(逗号,点,null)

我的控制器看起来像这样:

 public class PortefeuilleController : Controller
    {
            public ActionResult Create()
            {
                return View(new PortefeuilleViewModel{Saldo = 0.0});
            }
    }
Run Code Online (Sandbox Code Playgroud)

我的创建视图如下所示:

@model PortefeuilleViewModel

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>PortefeuilleViewModel</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Naam)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Naam)
            @Html.ValidationMessageFor(model => model.Naam)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Saldo)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Saldo)
            @Html.ValidationMessageFor(model => model.Saldo)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}
Run Code Online (Sandbox Code Playgroud)

我的PortefeuilleViewModel看起来像这样:

public class …
Run Code Online (Sandbox Code Playgroud)

c# validation asp.net-mvc

5
推荐指数
1
解决办法
1万
查看次数

XSLT:如果检查参数值

下面是xslt中的代码(我删除了不相关的部分,get-textblock更长,并且有很多参数都正确传递):

<xsl:template name="get-textblock">
        <xsl:param name="style"/>

        <xsl:element name="Border">         
            <xsl:if test="$style='{StaticResource LabelText}'" >
                <xsl:attribute name="Background">#FF3B596E</xsl:attribute>
            </xsl:if>
            <xsl:attribute name="Background">#FF3B5940</xsl:attribute>              
        </xsl:element>

</xsl:template>
Run Code Online (Sandbox Code Playgroud)

style参数可以是'{StaticResource LabelText}'或'{StaticResource ValueText}',边框的背景取决于该值.

但是,如果结构失败,它总是在我的output.xaml文件中绘制FF3B5940边框.我这样称呼模板:

<xsl:call-template name="get-textblock">
    <xsl:with-param name="style">{StaticResource LabelText}</xsl:with-param>                    
</xsl:call-template>
Run Code Online (Sandbox Code Playgroud)

有谁看到可能是什么问题?谢谢.

xslt

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

如何使图像自动调整大小以使宽度为100%并相应调整高度?

我有以下简单的XAML页面:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Test.UserGuides.VPN">
    <ContentPage.Content>
        <ScrollView>
            <StackLayout HorizontalOptions="Center" VerticalOptions="Center" Margin="10,10,10,10">
                <Label Margin="10,10,10,10" Text="How to connect to VPN." HorizontalOptions="Center" />
                <Label Margin="10,10,10,10" Text="If you have a corporate notebook, look for the Cisco AnyConnect application. Either in your start menu, on your desktop, or in your taskbar." />
                <Image x:Name="imgVPN1" Margin="10,10,10,10" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
                <Label Margin="10,10,10,10" Text="Select your region and press the Connect button." />
            </StackLayout>
        </ScrollView>
    </ContentPage.Content>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

在构造函数中,我调用一个方法来加载图像:

private void LoadImages()
{
    imgVPN1.Aspect = Aspect.AspectFit; …
Run Code Online (Sandbox Code Playgroud)

xamarin.forms

3
推荐指数
1
解决办法
7201
查看次数

为什么在Java中停止线程如此困难?

我再次出现在其中一种情况下,它不可能停止/销毁/暂停一个线程..interrupt()没有这个技巧,并且不推荐使用.stop()和.suspend().

很简单的例子:

public class TimerThread extends Thread {

    private JPanel colorPanel;

    public TimerThread(JPanel colorPanel) {
        this.colorPanel = colorPanel;
    }

    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
                colorPanel.repaint();
            } catch (Exception ex) {
                //do Nothing
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这样做是每秒重新绘制一个JPanel来改变它的颜色.我想从另一个类开始和停止这样的线程:

timer = new Thread(new TimerThread(colorPanel));

    startButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            timer.start();
        }
    });

    stopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            timer.interrupt();
        }
    });
Run Code Online (Sandbox Code Playgroud)

显然(?)这不起作用...我知道我可以使用Timer,SwingWorker或声明计时器,timer = new TimerThread(colorPanel);并在run方法中使用布尔值而不是"true",但我被要求声明计时器作为"线程",没有别的.

令我惊讶的是(或者这是愚蠢的?),即使这样也行不通:

startButton.addActionListener(new ActionListener() {
        public …
Run Code Online (Sandbox Code Playgroud)

java multithreading

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

php相对路径和目录

我想知道一些事情,但我似乎无法找到一个好的,明确的答案,甚至是解决这个问题的方法:

我的PHP网站具有以下结构:

root
   functions
   generators
   helpers
   scripts
   style
   index.php
Run Code Online (Sandbox Code Playgroud)

这些都是文件夹和一个php文件.函数包含一堆与数据库连接相关的op php文件和各种其他数据库操作,如插入,删除,更新......生成器包含自动生成网页的类,使它们看起来完全相同.助手是处理登录,注销,注册等的类.脚本是javascript,Style是CSS.

在我的generator文件夹中,有一个文件mainGenerator.php,它会生成网站的各个部分:

 private function generateLogin()
    {
        if (!isLoggedIn()) {
            echo "
                <h2>Login</h2>
                <form method='post' action='../helpers/login.php' id='loginForm'>
                <p>
                Username:<br/>
                <input class='search' type='text' name='username'/>
                Password:<br/>
                <input class='search' type='password' name='password'/>
                <input name='login' type='image' style='border: 0; margin: 0 0 -9px 5px;' src='style/login.png' alt='Login' title='Login'/><br/>
                No account yet? <a href='../register.php'>Register</a>
                </p></form>";
        } else {
            echo "
                <h2>Welome, <a href='user.php' style='color: #1293EE;'>" .
                 $_SESSION['user_name'] .
                 "</a></h2>
                <a href='logout.php'>Log off</a>";
        }
    }
Run Code Online (Sandbox Code Playgroud)

这段代码在每个页面上生成登录框,或者如果用户已经登录则显示欢迎消息.正如您所看到的,该操作引用了"../helpers/login.php",因为这是相对位置从这个生成器的角度来看loginhelper.

现在,问题出现了:如果我按下index.php(http://example.com/ProjectName/index.php)上的登录按钮,它会将我重定向到http://example.com/helpers/login.php …

php directory relative-path

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