Struts2 동적 지정 결과
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
set get
<ol>
<li><a href="user/user?type=1"> success</a></li>
<li><a href="user/user?type=2"> error</a></li>
</ol>
</body>
</html>
struts.xml 코드<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.i18n.encoding" value="UTF-8"></constant>
<constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant>
<package name="login" extends="struts-default" namespace="/user">
<action name="user" class="com.lbx.action.UserAction">
<result>${r}</result>
</action>
</package>
</struts>
Useraction 코드package com.lbx.action;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class UserAction extends ActionSupport{
private int type;
private String r;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getR() {
return r;
}
public void setR(String r) {
this.r = r;
}
@Override
public String execute() throws Exception {
if(type==1){r="/success.jsp";}
if(type==2){r="/error.jsp";}
return SUCCESS;
}
}
success.jsp와 error.jsp이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
프로덕션을 위한 SolrCloud 설정이 작업을 시작했을 때 SolrCloud에 익숙하지 않았습니다. 하지만 시간이 지나면서 요령이 생겼고 프로덕션 서버에서 SolrCloud를 설정하기 위한 최신 가이드를 작성하는 것이 좋은 생각이라고 생각합니다. 공식...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.