本文整理汇总了Java中org.springframework.web.bind.ServletRequestUtils.getStringParameters方法的典型用法代码示例。如果您正苦于以下问题:Java ServletRequestUtils.getStringParameters方法的具体用法?Java ServletRequestUtils.getStringParameters怎么用?Java ServletRequestUtils.getStringParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.bind.ServletRequestUtils
的用法示例。
在下文中一共展示了ServletRequestUtils.getStringParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequestInternal
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
String[] sidWebApps = ServletRequestUtils.getStringParameters(request, "sid_webapp");
for (int i = 0; i < sidWebApps.length; i++) {
if (sidWebApps[i] != null) {
String[] ss = sidWebApps[i].split(";");
if (ss.length == 2) {
String sessionId = ss[0];
String appName = ss[1];
Context context = getContainerWrapper().getTomcatContainer().findContext(appName);
if (context != null) {
Manager manager = context.getManager();
Session session = manager.findSession(sessionId);
if (session != null && session.isValid()) {
session.expire();
}
} else {
return new ModelAndView("errors/paramerror");
}
} else {
return new ModelAndView("errors/paramerror");
}
}
}
return new ModelAndView(new InternalResourceView(getViewName()));
}
示例2: handleRequestInternal
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
for (String sidWebApp : ServletRequestUtils.getStringParameters(request, "sid_webapp")) {
if (sidWebApp != null) {
String[] ss = sidWebApp.split(";");
if (ss.length == 2) {
String sessionId = ss[0];
String appName = ss[1];
Context context = getContainerWrapper().getTomcatContainer().findContext(appName);
if (context != null) {
Manager manager = context.getManager();
Session session = manager.findSession(sessionId);
if (session != null && session.isValid()) {
session.expire();
}
} else {
return new ModelAndView("errors/paramerror");
}
} else {
return new ModelAndView("errors/paramerror");
}
}
}
return new ModelAndView(new InternalResourceView(getViewName()));
}
示例3: processFormSubmission
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
* @see org.springframework.web.servlet.mvc.SimpleFormController#processFormSubmission(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
@Override
protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse reponse, Object obj,
BindException errors) throws Exception {
Encounter encounter = (Encounter) obj;
try {
if (Context.isAuthenticated()) {
Context.addProxyPrivilege(PrivilegeConstants.GET_USERS);
Context.addProxyPrivilege(PrivilegeConstants.GET_PATIENTS);
if (encounter.getEncounterId() == null && StringUtils.hasText(request.getParameter("patientId"))) {
encounter.setPatient(Context.getPatientService().getPatient(
Integer.valueOf(request.getParameter("patientId"))));
}
if (encounter.isVoided()) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "voidReason", "error.null");
}
String[] providerIdsArray = ServletRequestUtils.getStringParameters(request, "providerIds");
if (ArrayUtils.isEmpty(providerIdsArray)) {
errors.reject("Encounter.provider.atleastOneProviderRequired");
}
String[] roleIdsArray = ServletRequestUtils.getStringParameters(request, "encounterRoleIds");
ProviderService ps = Context.getProviderService();
EncounterService es = Context.getEncounterService();
if (providerIdsArray != null && roleIdsArray != null) {
//list to store role provider mappings to be used below to detect removed providers
List<String> unremovedRoleAndProviders = new ArrayList<String>();
for (int i = 0; i < providerIdsArray.length; i++) {
if (StringUtils.hasText(providerIdsArray[i]) && StringUtils.hasText(roleIdsArray[i])) {
unremovedRoleAndProviders.add(roleIdsArray[i] + "-" + providerIdsArray[i]);
Provider provider = ps.getProvider(Integer.valueOf(providerIdsArray[i]));
EncounterRole encounterRole = es.getEncounterRole(Integer.valueOf(roleIdsArray[i]));
//if this is an existing provider, don't create a new one to avoid losing existing
//details like dateCreated, creator, uuid etc in the encounter_provider table
if (encounter.getProvidersByRole(encounterRole).contains(provider)) {
continue;
}
//this is a new provider
encounter.addProvider(encounterRole, provider);
}
}
//Get rid of the removed ones
for (Map.Entry<EncounterRole, Set<Provider>> entry : encounter.getProvidersByRoles().entrySet()) {
for (Provider p : entry.getValue()) {
if (!unremovedRoleAndProviders.contains(entry.getKey().getEncounterRoleId() + "-"
+ p.getProviderId())) {
encounter.removeProvider(entry.getKey(), p);
}
}
}
}
ValidationUtils.invokeValidator(new EncounterValidator(), encounter, errors);
}
}
finally {
Context.removeProxyPrivilege(PrivilegeConstants.GET_USERS);
Context.removeProxyPrivilege(PrivilegeConstants.GET_PATIENTS);
}
return super.processFormSubmission(request, reponse, encounter, errors);
}
示例4: updatePersonNames
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
* Updates person names based on request parameters
*
* @param request
* @param person
*/
protected void updatePersonNames(HttpServletRequest request, Person person) {
Object[] objs = null;
objs = person.getNames().toArray();
for (int i = 0; i < objs.length; i++) {
if (request.getParameter("names[" + i + "].givenName") == null) {
person.removeName((PersonName) objs[i]);
}
}
//String[] prefs = request.getParameterValues("preferred"); (unreliable form info)
String[] gNames = ServletRequestUtils.getStringParameters(request, "givenName");
String[] mNames = ServletRequestUtils.getStringParameters(request, "middleName");
String[] fNamePrefixes = ServletRequestUtils.getStringParameters(request, "familyNamePrefix");
String[] fNames = ServletRequestUtils.getStringParameters(request, "familyName");
String[] fName2s = ServletRequestUtils.getStringParameters(request, "familyName2");
String[] fNameSuffixes = ServletRequestUtils.getStringParameters(request, "familyNameSuffix");
String[] degrees = ServletRequestUtils.getStringParameters(request, "degree");
String[] namePrefStatus = ServletRequestUtils.getStringParameters(request, "preferred");
if (gNames != null) {
for (int i = 0; i < gNames.length; i++) {
if (!"".equals(gNames[i])) { //skips invalid and blank address data box
PersonName pn = new PersonName();
if (namePrefStatus != null && namePrefStatus.length > i) {
pn.setPreferred(new Boolean(namePrefStatus[i]));
}
if (gNames.length >= i + 1) {
pn.setGivenName(gNames[i]);
}
if (mNames.length >= i + 1) {
pn.setMiddleName(mNames[i]);
}
if (fNamePrefixes.length >= i + 1) {
pn.setFamilyNamePrefix(fNamePrefixes[i]);
}
if (fNames.length >= i + 1) {
pn.setFamilyName(fNames[i]);
}
if (fName2s.length >= i + 1) {
pn.setFamilyName2(fName2s[i]);
}
if (fNameSuffixes.length >= i + 1) {
pn.setFamilyNameSuffix(fNameSuffixes[i]);
}
if (degrees.length >= i + 1) {
pn.setDegree(degrees[i]);
}
person.addName(pn);
}
}
Iterator<PersonName> names = person.getNames().iterator();
PersonName currentName = null;
PersonName preferredName = null;
while (names.hasNext()) {
currentName = names.next();
if (currentName.isPreferred()) {
if (preferredName != null) { // if there's a preferred name already exists, make it preferred=false
preferredName.setPreferred(false);
}
preferredName = currentName;
}
}
if ((preferredName == null) && (currentName != null)) { // No preferred name. Make the last name entry as preferred.
currentName.setPreferred(true);
}
}
}