小编Set*_* IK的帖子

在war存档中读取文本文件

我正在尝试从我的war存档中读取文本文件,并在运行时在facelets页面中显示内容.我的文件夹结构如下

+ war archive> + resources> + email> + file.txt

我尝试使用以下代码读取resources/email/file.txt文件夹中的文件

File file = new File("/resources/email/file.txt");
BufferedReader reader = null;
try {
    reader = new BufferedReader(new FileReader(file));
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
StringBuffer buffer = new StringBuffer();
if (reader != null) {
    String line = reader.readLine();
    while (line != null) {
        buffer.append(line);
        line = reader.readLine();
// other lines of code
Run Code Online (Sandbox Code Playgroud)

然而问题是当我运行上面代码的方法时,FileNotFoundException抛出了A. 我也尝试使用以下代码行来获取文件,但是没有成功

File file = new File(FacesContext.getCurrentInstance()
        .getExternalContext().getRequestContextPath() + "/resources/email/file.txt");
Run Code Online (Sandbox Code Playgroud)

我还是得到了 …

java jsf

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

在ASP.NET mvc 4中使用Ninject时是否需要控制器工厂

在使用Ninject和asp.net mvc 4时,我无法通过谷歌的.net提供大量文档.

首先,我想知道在asp.net中是否需要Controller工厂.

另外,构造函数注入真的是我们可以用MVC 4进行依赖注入的唯一方法,因为当我将它们与我的控制器一起使用时,属性注入和方法注入似乎不起作用

asp.net ninject

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

如何在ASP.NET MVC项目中使用Material-UI

有没有一种方法可以使用Material-UI,而不必使用NodeJS安装所有依赖项。我很想在ASP.NET项目中使用它,但是不知道从哪里开始安装依赖项以及所有这些。

material-ui

7
推荐指数
1
解决办法
6027
查看次数

在运行时绑定Ninject

我正在查看我正在处理的应用程序中的某个场景

我希望管理员能够在应用程序中更改系统范围的设置.

public class ApplicationSettings
{
 //bla bla bla

 }
Run Code Online (Sandbox Code Playgroud)

在startUp,我有以下绑定

public static void RegisterServices(IKernel kernel)
{
  kernel.Bind<ApplicationSettings>().ToSelf().InSingletonScope();
}
Run Code Online (Sandbox Code Playgroud)

一切都很好,因为据我了解,只要内核处于活动状态,就会提供相同的应用程序设置实例

我的问题是这个.如果我必须在运行时更改应用程序设置,该怎么办?我想自动更改内核中ApplicationSettings实例的值

是否可以做这样的事情

public void ChangeSettings(IKernel kernel, ApplicationSettings setting)
{
   var setting = kernel.Get<ApplicationSettings>();
   //change the values of the instance
}
Run Code Online (Sandbox Code Playgroud)

问题,如何更新内核绑定,以便后续对单例实例的引用将引用新修改的版本

谢谢

c# asp.net-mvc ninject

6
推荐指数
1
解决办法
2349
查看次数

在IIS Express中测试SignalR应用程序

大家好,我正在使用Visual Studio 2012,并开发了一个简单的应用程序,仅用于审查目的

但是我被困了,因为当我尝试预览应用程序时,我收到以下错误消息

[PlatformNotSupportedException: This operation requires IIS integrated pipeline mode.]
   System.Web.HttpResponse.get_Headers() +9681446
   System.Web.HttpResponseWrapper.get_Headers() +9
   Microsoft.Owin.Host.SystemWeb.OwinCallContext.CreateEnvironment() +309
   Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.GetInitialEnvironment(HttpApplication application) +246
   Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.PrepareInitialContext(HttpApplication application) +15
   Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.BeginEvent(Object sender, EventArgs e, AsyncCallback cb, Object extradata) +288
   System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +285
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Run Code Online (Sandbox Code Playgroud)

关于如何解决这个问题的任何想法

asp.net-mvc iis-express signalr

6
推荐指数
1
解决办法
7364
查看次数

&lt;h:commandButton&gt; 不启动回发

我在 JBoss AS 7.1.1 上使用 JSF 2.1.7 和 Myfaces CODI 1.0.5。我<h:commandButton>的不工作。我已经阅读了要求并通过许多博客中的示例都无济于事。我的facelets代码如下

<ui:define name="pagecontent">  
    <h1 class="title ui-widget-header ui-corner-all">Upload Bulk Contact File</h1>
    <div class="entry">
        <h:form enctype="multipart/form-data" id="upload">
            <p:panel closable="false" collapsed="false" header="Excel Contact Uploader"
                id="pnlupload" rendered="true" toggleable="false" visible="true" widgetVar="pnlupload">
                <p:growl id="msg"  showDetail="true" life="3000" showSummary="true"/>
                <p:fileUpload auto="true" 
                    allowTypes="/(\.|\/)(xls)$/" 
                    sizeLimit="1024000" 
                    mode="advanced" 
                    multiple="true" invalidFileMessage="Invalid file type" invalidSizeMessage="File too
                    large" dragDropSupport="true" 
                    fileUploadListener="#{excelFileController.handleFileUpload}" showButtons="true"
                    update="msg, tblcontacts" required="false"/>
                <p:scrollPanel rendered="true" style="height:200px;">
                    <p:dataTable draggableColumns="false" editable="false" emptyMessage="No 
                        Contacts Uploaded" id="tblcontacts" rendered="true"  rows="8"
                        selection="#{excelFileController.contactsSelected}" 
                        value="#{excelFileController.contactDataModel}" var="contact" style="width:50pc;">
                        <p:column selectionMode="multiple" style="width:18px" …
Run Code Online (Sandbox Code Playgroud)

primefaces cdi jsf-2

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

在 ReactJs 中计算来自 TextArea 的字符

我有一些我想在 react 中实现的东西,它是一个简单的功能,可以计算在 textarea 中输入了多少字符。

这是源代码

var WordCount = React.createClass({

getInitialState: function() {
    return{ contacts: [], fullName: "What Ever", smsBalance: 0, command: 'Send Now', charsPerPage: 160, pageCount:0 };
},

wordCount: function(e){

    var currentText = e.target.value;
    //Now we need to recalculate the number of characters that have been typed in so far
    var characterCount = currentText.length;
    var charsPerPageCount = this.state.charsPerPage;
    var unitCount = Math.round(characterCount/charsPerPageCount);
    this.setState({pageCount: unitCount});
},

render: function() {
    return(
        <div className="md-card">


        <div className="user_content">
            <ul className="uk-margin">
                <div className="uk-margin-top">

                    <div className="uk-grid" …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

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

weld-osgi入门

最近我读了这篇文章 以及这个公告,基本上是针对焊接osgi版本.

我真的很感兴趣如何在JBoss AS 7.1.x中使用它.有人可以指点我一个有效的解决方案吗?

谢谢

java osgi jboss7.x weld

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

Bootstrap JavaScript适用于localhost,但不适用于webhost

我正在使用Twitter Bootstrap使用Buget安装到ASP.NET MVC应用程序.然而,我很惊讶地发现我曾经在localhost上工作的所有引导程序JavaScript,实际上在上传到我的网络托管服务提供商时仍然停止工作.

我完全被这个碰到了,我似乎无法弄清楚出了什么问题.

asp.net-mvc-4 twitter-bootstrap

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

Protobuf 消息平台是否独立

我正在计划一个应用程序,其中服务器端将用 C# 编写,客户端将使用phonegap 创建

该应用程序大量使用使用 protobuf-net 库序列化的二进制文件。

假设我有一个 C# 对象

public class Foo
{
   private string FooProp;
}
Run Code Online (Sandbox Code Playgroud)

并且该对象被序列化并使用phonegap传输到客户端。是否可以反序列化phonegap中生成的二进制文件并使用Javascript访问phonegap中的这些属性?

c# asp.net protocol-buffers protobuf-net cordova

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

不支持表达式类型:System.Linq.Expressions.TypedParameterExpression

我正在做一个项目.我有以下模型

public class RegistrantClass : IRavenEntity
{
   public RegistrantClass()
   {
       RegistrantId = new List<string>();
   }
   public int Id { get; set; }

   public IList<String> RegistrantId { get; set; }

   public String ClassId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我定义了以下索引

        store.DatabaseCommands.PutIndex("RegistrantClass/ClassByStudents",
                            new IndexDefinitionBuilder<RegistrantClass>
                            {
                                Map = students => from i in students
                                                  from j in i.RegistrantId
                                                  select new { j }
                            });
Run Code Online (Sandbox Code Playgroud)

我试着像这样查询上面的索引

public object GetMapping(string registrantId)
{
 var mapping = _session.Query<RegistrantClass>("RegistrantClass/ClassByStudents")
                             .Customize(i => i.Include<RegistrantClass>(k => k.RegistrantId))
                             .Customize(i => i.Include<RegistrantClass>(k => k.ClassId)) …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc ravendb

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

Autofac单实例

我有以下问题了解单实例绑定的工作原理

我有以下课程列表

public interface ICacheManager
{
    object Get(string key);

    void Set(string key, object data, int cacheTime);

    bool IsSet(string key);

    void Invalidate(string key);
}
Run Code Online (Sandbox Code Playgroud)

实施如下

public class MemoryCacheManager : ICacheManager
{
    private ObjectCache Cache
    {
        get { return MemoryCache.Default; }
    }

    public object Get(string key)
    {
        return Cache[key];
    }

    public void Set(string key, object data, int cacheTime)
    {

        var policy = new CacheItemPolicy { AbsoluteExpiration = DateTime.Now + TimeSpan.FromMinutes(cacheTime) };
        Cache.Add(new CacheItem(key, data), policy);
    }

    public bool IsSet(string key)
    {
        return …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc autofac

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