JSP将参数传递给模式

时间:2019-01-05 10:00:02

标签: java jsp modal-dialog

曾经试图自己弄清楚这一点,但没有运气,所以我在这里寻求帮助。 试图将参数传递给同一页面上的模态。 这是代码:

# Called using `Get-SystemState services,volumes`
# Requires the folder %ProgramData%\VACS\states`

function Get-SystemState {

    Param (
        [Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true,ParameterSetName='Targets')]
        [ValidateNotNullOrEmpty()]
        [string[]]
        $Targets
    )

    begin {
        $Data = New-Object -TypeName PSObject
        Add-Member -InputObject $Data -NotePropertyName "state_changes" -NotePropertyValue ([PSCustomObject]@{}) -force
        $FilePath = "$Env:PROGRAMDATA\VACS\states\"
    }

    process {
        foreach($Target in $Targets){
            switch ($Target) {
                services {
                    $State = gwmi win32_service | Select-Object Name, Status, ExitCode, ErrorControl, PathName, StartMode, 
                                    Caption, DelayedAutoStart, Description, DisplayName, InstallDate, ServiceSpecificExitCode, 
                                    Started, StartName, State
                    $Snapshot = Get-Content -Raw -Path (Join-Path "$FilePath" "$Target.json") | ConvertFrom-Json
                    $Changes = (Compare-Object -ReferenceObject ($Snapshot) -DifferenceObject ($State) `
                                        -Property Name, Status, ExitCode, ErrorControl, PathName, StartMode,DelayedAutoStart, 
                                        DisplayName, InstallDate, ServiceSpecificExitCode, Started, StartName, State |
                                        ForEach-Object {
                                            $_.SideIndicator = $_.SideIndicator -replace "=>","previous_state" -replace "<=","current_state"
                                            $_
                                        })
                }
                volumes {
                    $State = Get-Volume | Select-Object OperationalStatus,HealthStatus,DriveType,FileSystemType, DedupMode,UniqueId,
                                AllocationUnitSize,FileSystemLabel,FileSystem,Size,
                                @{n='DriveLetter';e={if([string]::IsNullOrEmpty($_.DriveLetter)){""}else{$_.DriveLetter}}}

                    $Snapshot = Get-Content -Raw -Path (Join-Path "$FilePath" "$Target.json") | ConvertFrom-Json
                    $Changes = (Compare-Object -ReferenceObject ($Snapshot) -DifferenceObject ($State) `
                                    -Property OperationalStatus,HealthStatus,DriveType,FileSystemType,DedupMode,UniqueId,AllocationUnitSize,
                                    FileSystemLabel,FileSystem,Size,DriveLetter |
                                    ForEach-Object {
                                        $_.SideIndicator = $_.SideIndicator -replace '=>','previous_state' -replace '<=','current_state'
                                        $_
                                    })
                }
            }

            if($Changes.Count -gt 0){

                Add-Member -InputObject $Data."state_changes" -NotePropertyName $Target -NotePropertyValue ([PSCustomObject]@{}) -force
                Add-Member -InputObject $Data."state_changes".$Target -NotePropertyName "timestamp" -NotePropertyValue "$((Get-Date).ToString())" -force

                write-host $Changes.Count "changes detected in $Target"

                For($i=0; $i -lt $Changes.Count; $i++){
                    Add-Member -MemberType NoteProperty -InputObject $Data."state_changes".$Target -NotePropertyName $i -NotePropertyValue $Change -force
                }


            }
            $State | ConvertTo-Json | Set-Content -Path (Join-Path "$FilePath" "$Target.json") -Force
        }
    }

    end {
        Send-Payload $Data
    }
}

当您在链接...... <!-- Table --> <table class="table table-bordered" width="100%" cellspacing="0"> <thead> <tr> <th>Id</th> <th>Name</th> <th>Description</th> <th>Action</th> </tr> </thead> <tbody> <tr> <td><%=resultSet.getString("Id") %></td> <td><%=resultSet.getString("name") %></td> <td><%=resultSet.getString("description")%></td> <td> <div> <a href='' data-target='#updateProduct?u=<%=resultSet.getString("product_code")%>' data-toggle="modal">Update</a> </div> </td> </tr> </tbody> </table> <!-- Table end --> <!-- Update Modal --> <% try{ connection = DriverManager.getConnection(connectionUrl+database, userid, password); statement=connection.createStatement(); String u = request.getParameter("u"); int productNumber = Integer.parseInt(u); String searchVal = request.getParameter("searchCostume"); String sql = "Select * from product where product_code = '"+productNumber+"' "; //String sql ="Select * from product where admin_id = '"+session.getAttribute( "adminID" )+"'"; ; //String sql ="Select * from post JOIN customer USING(FirstName) where FirstName="+session.getAttribute( "Name" ); int i=0; resultSet = statement.executeQuery(sql); while(resultSet.next()){ %> <div class="modal fade" id="updateProduct" tabindex="-1" role="dialog" aria-labelledby="Modal" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Update Costume</h5> <button class="close" type="button" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"><form action="insertRegistration.jsp" method="post"> <div class="form-group"> <div class="form-row"> <div class="col-md-6"> <label for="inputEmail">Id</label> <div class="form-label-group"> <input value='<%=resultSet.getString("id")%>' type="text" name="prodCode" class="form-control" autofocus="autofocus" readonly> </div> </div> </div> </div> <div class="form-group"> <div class="form-row"> <div class="col-md-6"> <label for="inputPassword">Name</label> <div class="form-label-group"> <input value='<%=resultSet.getString("id")%>' autocomplete='off' type="password" name="prodName" class="form-control" required="required"> </div> </div> </div> </div> <div class="form-group"> <div class="form-row"> <div class="col-md-6"> <label for="firstName">Description</label> <div class="form-label-group"> <input value='<%=resultSet.getString("description")%>' maxlength="20" autocomplete='off' type="text" name="firstName" class="form-control" required="required"> </div> </div> </div> </div> </div> </div> </div> </div> <% i++; } connection.close(); } catch (Exception e) { e.printStackTrace(); } %> <!-- Modal end --> 中传递参数时,我试图以通常的方式传递参数,但是这样做不起作用 欢迎任何帮助 预先感谢。

0 个答案:

没有答案