我使用function getwmiinfo ($svr) {
gwmi -Query "select * from Win32_ComputerSystem" -ComputerName $svr |
select Name, Model, Manufacturer, Description, DNSHostName, Domain,
DomainRole, PartOfDomain, NumberOfProcessors, SystemType,
TotalPhysicalMemory, UserName, Workgroup |
Format-Table -Property * -Autosize | Out-String -Width 10000
gwmi -Query "select * from Win32_OperatingSystem" -ComputerName $svr |
select Name, Version, FreePhysicalMemory, OSLanguage, OSProductSuite,
OSType, ServicePackMajorVersion, ServicePackMinorVersion |
Format-Table -Property * -Autosize | Out-String -Width 10000
gwmi -Query "select * from Win32_PhysicalMemory" -ComputerName $svr |
select Name, Capacity, DeviceLocator, Tag |
Format-Table -Autosize
gwmi -Query "select * from Win32_LogicalDisk where DriveType=3" -ComputerName $svr |
select Name, FreeSpace, Size |
Format-Table -Autosize
}
$servers = Get-Content 'servers.txt'
foreach ($server in $servers) {
$results = gwmi -query "select StatusCode from Win32_PingStatus where Address = '$server'"
$responds = $false
foreach ($result in $results) {
if ($result.statuscode -eq 0) {
$responds = $true
break
}
}
if ($responds) {
getwmiinfo $server
} else {
Write-Output "$server does not respond"
}
}
来支持多语言。
我无法发送"到ReloadableResourceBundleMessageSource
" build"的参数消息。
我在屏幕上显示的消息是ReloadableResourceBundleMessageSource.getMessage()
,但我希望看到the fields are {0} and {1}
重要提示:在我的方案中,我无法使用the fields are name and surname
,我必须以编程方式打印消息。
这是在.xml文件中定义的bean:
spring:message
这是我称之为<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>WEB-INF/I18n/dao/dao</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8" />
<property name="cacheSeconds" value="1"/>
</bean>
ReloadableResourceBundleMessageSource.getMessage()
这是控制器,我打电话给public class I18nMessageHandler {
@Autowired
private ReloadableResourceBundleMessageSource messageSource;
public String printMessage() {
...
return messageSource.getMessage("messageA", new Object[] { "name", "surname" }, LocaleContextHolder.getLocale());
...
}
}
I18nMessageHandler.printMessage()
这是jsp页面
@Controller
public class indexController {
@Autowired
private I18nMessageHandler i18nMessageHandler;
@RequestMapping("/index")
public String index(Model model) {
model.addAttribute("message", i18nMessageHandler.printMessage());
return "index";
}
}
这是文件属性:
${message}
你能发现我的错误吗?
谢谢。