GVKun编程网logo

在不重新启动servlet容器的情况下重新加载/刷新Spring配置文件(springboot不重启加载yml)

26

在这里,我们将给大家分享关于在不重新启动servlet容器的情况下重新加载/刷新Spring配置文件的知识,让您更了解springboot不重启加载yml的本质,同时也会涉及到如何更有效地c#–如何在

在这里,我们将给大家分享关于在不重新启动servlet容器的情况下重新加载/刷新Spring配置文件的知识,让您更了解springboot不重启加载yml的本质,同时也会涉及到如何更有效地c# – 如何在不重新加载页面的情况下刷新下拉列表?、C#Selenium-在不重新启动Chrome浏览器的情况下更新代理、javascript – 在不重新加载整个页面的情况下重新执行js、javascript – 如何在不刷新整个页面的情况下重新加载DIV内容的内容。

本文目录一览:

在不重新启动servlet容器的情况下重新加载/刷新Spring配置文件(springboot不重启加载yml)

在不重新启动servlet容器的情况下重新加载/刷新Spring配置文件(springboot不重启加载yml)

如何在不重新启动servlet容器的情况下刷新Spring配置文件?

我正在寻找JRebel以外的解决方案。

答案1

小编典典

对于那些最近在这上面绊脚石的人来说,解决此问题的当前和现代方法是使用Spring Boot的Cloud Config。

只需添加@RefreshScope注释你刷新豆类和@EnableConfigServer你的主/配置。

因此,例如,以下Controller类:

@RefreshScope@RestControllerclass MessageRestController {    @Value("${message}")    private String message;    @RequestMapping("/message")    String getMessage() {        return this.message;    }}

在Spring Boot Actuator上(通过HTTP端点或JMX)调用时,message将为/message端点返回String属性的新值refresh

c# – 如何在不重新加载页面的情况下刷新下拉列表?

c# – 如何在不重新加载页面的情况下刷新下拉列表?

我的页面中有两个下拉列表:
<asp:DropDownList AutopostBack="True" OnSelectedindexChanged="ddlMain_SelectedindexChanged" ClientIDMode="Static" ID="ddlMain" name="searchPhys"runat="server" AppendDataBoundItems="true">
    <asp:ListItem Text="BY PHYSICIAN" Value="0" Selected="True" />
    <asp:ListItem Text="BY LOCATION" Value="1" />
    <asp:ListItem Text="BY SPECIALTY" Value="2" />
</asp:DropDownList>

<br /><br />

<asp:DropDownList ClientIDMode="Static" ID="ddlDrillDown" name="searchPhys"runat="server" AppendDataBoundItems="true">
</asp:DropDownList>

我处理下拉列表更改的代码隐藏是:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.sqlClient;
using System.Xml.Linq;
using System.Configuration;
using System.Windows.Forms;
using System.Data;

public partial class physicians : System.Web.UI.Page
{

    protected void Page_Load(object sender,EventArgs e) {

    if (!Page.IsPostBack) {
        PopulatePhysician();
    }
    //PopulateSpecialty();
    //PopulateLocation();

    }

    public void PopulatePhysician() {
        sqlCommand cmd = new sqlCommand("getPhysicians",new sqlConnection(ConfigurationManager.AppSettings["ConnString"]));
        //cmd.CommandType = Data.CommandType.StoredProcedure
        cmd.Connection.open();

        sqlDataReader ddlValues = default(sqlDataReader);
        ddlValues = cmd.ExecuteReader();

        //if (!IsPostBack) {
            ddlDrillDown.Items.Clear();
            ddlDrillDown.DataSource = ddlValues;
            ddlDrillDown.DataValueField = "content_id";
            ddlDrillDown.DataTextField = "content_title";
            ddlDrillDown.DataBind();
            //set the default value for the drop down
            ListItem Item = new ListItem();
            Item.Text = "Select a Physician's Name";
            Item.Value = "0";
            //Item.Selected = True
            ddlDrillDown.Items.Insert(0,Item);
        //}
    cmd.Connection.Close();
    cmd.Connection.dispose();
    }

    public void PopulateSpecialty() {
        sqlCommand cmd = new sqlCommand("getSpecialties",new sqlConnection(ConfigurationManager.AppSettings["ConnString"]));
        cmd.Connection.open();

        sqlDataReader ddlValues = default(sqlDataReader);
        ddlValues = cmd.ExecuteReader();

        //if (!IsPostBack) {
            ddlDrillDown.Items.Clear();
            ddlDrillDown.DataSource = ddlValues;
            ddlDrillDown.DataValueField = "content_id";
            ddlDrillDown.DataTextField = "content_title";
            ddlDrillDown.DataBind();
            //set the default value for the drop down
            ListItem Item = new ListItem();
            Item.Text = "Select a Specialty";
            Item.Value = "0";
            ddlDrillDown.Items.Insert(0,Item);
        //}
        cmd.Connection.Close();
        cmd.Connection.dispose();
    }

    public void PopulateLocation() {
        sqlCommand cmd = new sqlCommand("getLocations",new sqlConnection(ConfigurationManager.AppSettings["ConnString"]));
        cmd.Connection.open();

        sqlDataReader ddlValues = default(sqlDataReader);
        ddlValues = cmd.ExecuteReader();

        //if (!IsPostBack) {
            ddlDrillDown.Items.Clear();
            ddlDrillDown.DataSource = ddlValues;
            ddlDrillDown.DataValueField = "content_id";
            ddlDrillDown.DataTextField = "content_title";
            ddlDrillDown.DataBind();

            //set the default value for the drop down
            ListItem Item = new ListItem();
            Item.Text = "Select a Location";
            Item.Value = "0";
            ddlDrillDown.Items.Insert(0,Item);
        //}
        cmd.Connection.Close();
        cmd.Connection.dispose();
    }

    public void ddlMain_SelectedindexChanged(object sender,System.EventArgs e) {
        switch(ddlMain.Selectedindex) {
            case 0:
                PopulatePhysician();
                break;
            case 1:
                PopulateLocation();
                break;
            case 2:
                PopulateSpecialty();
                break;
        }
    }
}

我试图添加到上面的功能是,当用户从ddlMain下拉列表中选择一个选项,根据选项刷新ddlDrillDown下拉列表而不重新加载页面.

我怎样才能实现它?

更新:

<asp:ScriptManager ID="ScriptManager" 
                               runat="server" />
            <asp:UpdatePanel ID="UpdatePanel1" 
                             UpdateMode="Conditional"
                             runat="server">
                <ContentTemplate>
                    <asp:DropDownList AutopostBack="True" OnSelectedindexChanged="ddlMain_SelectedindexChanged" ClientIDMode="Static" ID="ddlMain"runat="server" AppendDataBoundItems="true">
                        <asp:ListItem Text="BY PHYSICIAN" Value="0" Selected="True" />
                        <asp:ListItem Text="BY LOCATION" Value="1" />
                        <asp:ListItem Text="BY SPECIALTY" Value="2" />
                    </asp:DropDownList>
                    <br /><br />
                    <asp:DropDownList ClientIDMode="Static" ID="ddlDrillDown"runat="server" AppendDataBoundItems="true">
                    </asp:DropDownList>
                    </ContentTemplate>
            </asp:UpdatePanel>

解决方法

使用AJAX.将两个下拉控件放在UpdatePanel中,并在页面中打开Form标签后添加一个ScriptManager(如果尚未存在)

C#Selenium-在不重新启动Chrome浏览器的情况下更新代理

C#Selenium-在不重新启动Chrome浏览器的情况下更新代理

如何解决C#Selenium-在不重新启动Chrome浏览器的情况下更新代理?

我正在创建一个机器人,该机器人可以访问网站,更改代理,然后重新加载网站。我想在循环中更新chrome Web驱动程序的代理,但是只有在使用新代理创建新的Web驱动程序时,我才找到一种方法。我只想更新当前的chrome驱动程序代理,而不要用新的代理创建一个新的代理。

            IWebDriver driver;
            for (int i = 0; i < listBoxNames.Items.Count; i++)
            {
                ChromeOptions settings = new ChromeOptions();
                Proxy Proxy = new Proxy();
                Proxy.Kind = ProxyKind.Manual;
                Proxy.IsAutoDetect = false;
                Proxy.SslProxy = Proxies[i];
                settings.Proxy = Proxy;
                settings.AddArgument("ignore-certificate-errors");
                driver = new ChromeDriver(settings);
            }

此代码每次在循环中循环时都会创建一个新的Web驱动程序。我该如何做,使其仅将新的代理更新为当前的Web驱动程序?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

javascript – 在不重新加载整个页面的情况下重新执行js

javascript – 在不重新加载整个页面的情况下重新执行js

有没有办法重新执行JS而不刷新页面?

假设我有一个父页面和一个内页.当调用内部页面时,它将通过ajax调用,替换父页面的内容.当用户点击回来时,我想将它们导航回父页面,而无需重新加载页面.但是,父页面UI依赖于javascript,所以在他们点击后,我想重新执行父页面的javascript.这可能吗?

编辑:这是一些代码.我将代码包装在一个函数中,但是你在哪里以及如何调用这个函数?

function executeGlobJs() {
   alert("js reload success");
}

解决方法

你可以使用html5 history-api:

在您的点击处理程序中,您将调用pushState方法,stat存储当前状态以供以后重用:

$(document).on('click','a.link',function () {
  // some ajax magic here to load the page content
  // plus something that replaces the content...  

  // execute your custom javascript stuff that should be called again
  executeGlobJs()

  // replace the browser-url to the new url
  // maybe a link where the user has clicked
  history.pushState(data,title,url);
})

…稍后如果用户浏览:

$(window).on('popstate',function () {
  // the user has navigated back,// load the content again (either via ajax or from an cache-object)
  // execute your custom stuff here...
  executeGlobJs()
})

这是一个非常简单的例子,当然不是完美的!
你应该在这里阅读更多相关信息:

> https://css-tricks.com/using-the-html5-history-api/
> https://developer.mozilla.org/en-US/docs/Web/API/History_API

对于ajax和DOM相关的部分,你应该学习一些关于jQuery http://api.jquery.com/jquery.ajax/.(这都是关于神奇的美元符号)

另一种选择是hashchange-event,如果你要支持旧的浏览器……

javascript – 如何在不刷新整个页面的情况下重新加载DIV内容

javascript – 如何在不刷新整个页面的情况下重新加载DIV内容

我想只用我得到的内容替换DIV内容.在我使用ajax向服务器发出get请求之后.

    $.ajax({
    type: "GET",
    url: "http://127.0.0.1:8000/result/?age="+ ageData +"&occasion="+ 
    occasionData     +"&relationship="+ forData +"#",

    success: function () {

        $("#testDIV").load();
    }
});

“testDIV”是我想要替换从服务器获取的内容的div的id.

解决方法:

   $.ajax({
type: "GET",
url: "ht.tp://127.0.0.1:8000/result/?age="+ ageData +"&occasion="+ 
occasionData     +"&relationship="+ forData +"#",

success: function (response) {

    $("#testDIV").html(response);
}
});

关于在不重新启动servlet容器的情况下重新加载/刷新Spring配置文件springboot不重启加载yml的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于c# – 如何在不重新加载页面的情况下刷新下拉列表?、C#Selenium-在不重新启动Chrome浏览器的情况下更新代理、javascript – 在不重新加载整个页面的情况下重新执行js、javascript – 如何在不刷新整个页面的情况下重新加载DIV内容等相关内容,可以在本站寻找。

本文标签: